Hello!
I really need help...
What it is, I have recently started to develop my brand new website. Now I have seen on various sites where you can click a link and I think using iFrames, you can open it in a specific bit of the website. Like open a job app it would open in like a content box.
Anyone know
Thanks!
Page 1 of 1
[URGENT] Open links in content box Help me please :D
#3
Posted 03 May 2009 - 12:34 PM
<script type="text/javascript">
//<![CDATA[
window.onload = function() {
var f = document.getElementById("mainframe");//Sets iframe id
function resize() { //Starts resize function
var h = "";
var w = "";
if (f.contentDocument) {
h = f.contentDocument.documentElement.offsetHeight + 20 + "px";
// can't find anything for Opera and Firefox that works for the width. OffetWidth doesn't work right either.(f.contentDocument.documentElement,"").getPropertyValue("width");
} else if (f.contentWindow) {
h = f.contentWindow.document.body.scrollHeight + 5 + "px";
} else {
return;
}
f.setAttribute("height",h);
f.parentNode.setAttribute("height",h);
}
if (window.addEventListener) {
f.onload = resize;
} else if (f.attachEvent) {
f.attachEvent("onload", resize);
} else {
return;
}
resize(); //starts resize function that was coded further up the code
}
//]]>
</script><iframe name="mainframe" id="mainframe" src="home.html" width="100%" frameborder="0" allowtransparency="yes" scrolling="No"></iframe>I tried this but didnt work.
When I inserted and tried to put default text when I opened another page it opened in the content box but 3/4 was cut off and there was a 404 error
...
#4
Posted 03 May 2009 - 04:53 PM
var f = document.getElementById("mainframe");//Sets iframe idNo. It gets the document control identified by "mainframe" and assigns it to a variable.
What is it that you think you are doing in that code? A 404 error indicates that the browser can not find the required resource.Judging by your code, I guess it expects the initial content to be something called 'home.html'.
These two lines:
h = f.contentDocument.documentElement.offsetHeight + 20 + "px"; h = f.contentWindow.document.body.scrollHeight + 5 + "px";
...assign a string to h, something that will look like '120px'. That is a string, not a number value, o when you are trying to do this:
f.setAttribute("height",h);
f.parentNode.setAttribute("height",h);...the javascript does not know what to do with h. It is expecting an int, and you are giving it a string.
The code that you got from here is wrong.
f.onload = resize;
That is not how to call a function. Function calls have parenthesis at the end, like f.onload = resize();
Throw out that javascript because you are never going to get anywhere with it. For starters, just try loading a default page into an iframe without worrying about the size; no javascript necessary for that.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens
Share this topic:
Page 1 of 1

Help


Back to top









