|
-
Feb 23rd, 2005, 11:16 PM
#1
Access denied error with JS
Here comes an other iFrame question. I am trying to resize the iFrame acording to it's height. And found a nice JS function:
Code:
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
But I am getting a JS error, access denied, on the first line. Anyone understand why? Is it because the content of the iFrame is on the other server or what?
ØØ
-
Feb 24th, 2005, 01:06 AM
#2
Re: Access denied error with JS
Again, are you running it from inside the IFRAME or outside the IFRAME?
-
Feb 24th, 2005, 01:13 AM
#3
Re: Access denied error with JS
[Little guy from Jerry McGuirre]You talk to much[/Little guy from Jerry McGuirre]
The function is in it's own js file. And I ran it like this (is this what is called in-line?):
Code:
<iframe width="700" id="the_iframe"
onLoad="calcHeight();"
src="testing_page.shtml"
scrolling="NO"
frameborder="1"
height="1">
</iframe>
So I guess that will say that it was the main page that called the function. And not called "from" the scr of the iFrame, if that was what you asked about.
Feel like a n00b for the first time in many years now...
ØØ
-
Feb 24th, 2005, 01:14 AM
#4
Re: Access denied error with JS
To add to that. This was the 2 simple steps that I tried to follow, and messed up anyway...
http://guymal.com/mycode/iframe_size/
-
Feb 24th, 2005, 01:20 AM
#5
Re: Access denied error with JS
Show me your page. I don't feel like creating an HTML file for this.
-
Feb 24th, 2005, 01:26 AM
#6
Re: Access denied error with JS
I have added the insanity back again. For your pleasure
:
Sample page comming up:
http://www.noteme.com/forum.php
js-file (only the first function, the two others was for an other test):
http://www.noteme.com/height.js
ØØ
-
Feb 24th, 2005, 01:40 AM
#7
Re: Access denied error with JS
Try this in the JS file:
Code:
document.getElementById('forum').document.body.scrollHeight
-
Feb 24th, 2005, 01:40 AM
#8
Re: Access denied error with JS
To not confuse you:
Code:
function calcHeight()
{
//find the height of the internal page
// var the_height = document.getElementById('forum').contentWindow.document.body.scrollHeight;
var the_height = document.getElementById('forum').document.body.scrollHeight;
//change the height of the iframe
document.getElementById('forum').height = the_height;
}
-
Feb 24th, 2005, 01:45 AM
#9
Re: Access denied error with JS
Sweet mother of J, that nearly worked.. ....at least the access problem is gone. But the size is still wrong.
I came over an other idea too. To send the info about the height from the web page in the iFrame (the forum), to the page that holds it. Will try that now, and get back to this thread if that fails..
ØØ
-
Feb 24th, 2005, 01:47 AM
#10
Re: Access denied error with JS
 Originally Posted by mendhak
To not confuse you:
Code:
function calcHeight()
{
//find the height of the internal page
// var the_height = document.getElementById('forum').contentWindow.document.body.scrollHeight;
var the_height = document.getElementById('forum').document.body.scrollHeight;
//change the height of the iframe
document.getElementById('forum').height = the_height;
}
I am not THAT easy to confuse... But thanks.. ...the error went away. Not sure why I can't use contentWindow, but it is probably a good reason..
-
Feb 24th, 2005, 01:51 AM
#11
Re: Access denied error with JS
I've never seen contentwindow being used with an IFRAME before. Then again, I haven't used many IFRAMES either. 
Either way, with Iframes, I generally work directly with the document.
-
Feb 24th, 2005, 02:00 AM
#12
Re: Access denied error with JS
I have never used iFrames before either. Was told about their existence just a few hours ago, and they have given me head aches the same amount of hours....
ØØ
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|