programmer-in-training Posted March 22, 2008 Share Posted March 22, 2008 Is it possible for JavaScript in a frame to call JavaScript functions that are not in the frame, the parent window? I am displaying dynamically generated output inside an <iframe>. (For scrollability; if I knew of a way to get a <div> to scroll it, I would use it...)The content in the <iframe> has onMouseOver events that used to call functions in the parent window when it was a <div>, but now that I am using an <iframe> it gives an error (object expected). Link to comment Share on other sites More sharing options...
djp1988 Posted March 22, 2008 Share Posted March 22, 2008 You can make a scrolling div, buy saying in the style of the div: overflow:auto; Tht is after of course you have defined a height and width... Link to comment Share on other sites More sharing options...
jeffman Posted March 23, 2008 Share Posted March 23, 2008 This is a very old school approach, but I believe it still works. In your frame set, give your frames names, like this:<frame src="frameA.html" name="frameA" />from frameB, call a function in frameA like this:parent.frameA.theFunction(); Link to comment Share on other sites More sharing options...
programmer-in-training Posted March 23, 2008 Author Share Posted March 23, 2008 Thanks! (I would just use parent.theFunction(), right? theFunction() isn't in a frame.) Link to comment Share on other sites More sharing options...
jhecht Posted March 23, 2008 Share Posted March 23, 2008 Yes. Or you could just make your div's have a set height/width and give them the overflow:auto; CSS attribute... whichever works. Link to comment Share on other sites More sharing options...
programmer-in-training Posted March 23, 2008 Author Share Posted March 23, 2008 I'd actually prefer that to an <iframe>! This site and w3schools have been very helpful. Link to comment Share on other sites More sharing options...
djp1988 Posted March 23, 2008 Share Posted March 23, 2008 Well I would be careful on the use of iframes because of the SEO issues, you'll have to work round the fact that the visitor can find your page alone which is only intended to appear within the iframe Link to comment Share on other sites More sharing options...
programmer-in-training Posted March 24, 2008 Author Share Posted March 24, 2008 What are SEO issues?My page isn't supposed to be in a frame, but it used to dynamically generate a frame and fill it with output. Now it uses a <div>. Link to comment Share on other sites More sharing options...
programmer-in-training Posted May 16, 2008 Author Share Posted May 16, 2008 Is there any way to get around these "Access denied" errors when you try to call a function running in a different frame/window? I think it's to stop illegal use of JavaScript, but I own both window and frame. (My main site and my blogspot.com site) I would like them to communicate, but nothing works.Does anyone know if I can somehow verify that I am the real owner and am allowed to do this? Link to comment Share on other sites More sharing options...
Ingolme Posted May 16, 2008 Share Posted May 16, 2008 It will only work if both pages are in the same domain, for security reasons. Link to comment Share on other sites More sharing options...
programmer-in-training Posted May 16, 2008 Author Share Posted May 16, 2008 I can't do that, because one is on my main site and the other is on my blog (on blogspot.com).Is there any way to tell it that I am allowed to do this? Link to comment Share on other sites More sharing options...
Ingolme Posted May 16, 2008 Share Posted May 16, 2008 No, there's no way, not with Javascript.The reason is simple: I can execute Javascript on any site I like by typing it in the navigation bar.So giving "permission" with Javascript to access other pages would be very easy to do if it was possible. Link to comment Share on other sites More sharing options...
programmer-in-training Posted May 16, 2008 Author Share Posted May 16, 2008 Is there an alternative? Link to comment Share on other sites More sharing options...
justsomeguy Posted May 19, 2008 Share Posted May 19, 2008 I don't know specifically what you're trying to do, but you might be able to use a PHP proxy. Javascript would send an AJAX request to a PHP page which would send the request to the page in the other domain and get the response back, then PHP could send the response back to the first Javascript. If the sites just need to exchange data then that would work, but you wouldn't be able to execute a specific Javascript function on an external page. Link to comment Share on other sites More sharing options...
programmer-in-training Posted June 25, 2008 Author Share Posted June 25, 2008 Well, each page on my site has a JS file referenced within it. I would like to reference the same JS file at "my blog".blogspot.com. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 25, 2008 Share Posted June 25, 2008 OK, you can have your blogspot page link to the same Javascript file, that shouldn't be a problem. Link to comment Share on other sites More sharing options...
programmer-in-training Posted June 26, 2008 Author Share Posted June 26, 2008 It won't let me run JS functions contained in the main site, if I'm at the blogspot site. Link to comment Share on other sites More sharing options...
justsomeguy Posted June 26, 2008 Share Posted June 26, 2008 "Contained in the main site" .. are you saying that you can't link to a script file on another domain from blogspot.com? Are you trying to embed an HTML or page or something and execute Javascript commands on that external HTML page, or are you just trying to link to a script file on another domain? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.