Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Why won't this work? 1

Status
Not open for further replies.

Kindon

Programmer
Apr 19, 2001
54
0
0
US
I have used the following code snippet in several pages. This is a copy and paste from a page that works to a new page that does not. The point of interest is the JavaScript that gets the iframe and its document. When I run this I get an error message saying "Access denied" on the line where I set myFrameDoc. What's up with this? This should be very simple.

Code:
<html>
<body>
  <iframe id=&quot;myframe&quot; src=&quot;[URL unfurl="true"]http://www.google.com&quot;[/URL] width=&quot;100&quot; height=&quot;100&quot;></iframe>
  <script language=&quot;javascript&quot;>
      myFrame = document.frames[&quot;myframe&quot;];
      myFrameDoc = myFrame.document;
  </script>
</body>
</html>
 
Is this page within another page/frame? You could overcome it if you give the frame a unique ID and grab it with

myFrame = document.getElementById(&quot;uniqueID&quot;)

Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

fart.gif
 
That is really odd. Using getElementById did not work on all my other pages. So I used the frames object instead. Now the problem is reversed. Anyway, all is well. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top