Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo

[URGENT] Open links in content box


  • Please log in to reply
3 replies to this topic

#1 JacobHall

JacobHall

  • Members
  • 300 posts
  • OFFLINE
  •  
  • Local time:09:50 PM

Posted 03 May 2009 - 10:09 AM

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!

BC AdBot (Login to Remove)

 


#2 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:50 PM

Posted 03 May 2009 - 10:22 AM

have you plugged iframe into your search engine to see what comes up? There are other ways it can be done also using ajax calls.

#3 JacobHall

JacobHall
  • Topic Starter

  • Members
  • 300 posts
  • OFFLINE
  •  
  • Local time:09:50 PM

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 :thumbsup:

#4 groovicus

groovicus

  • Security Colleague
  • 9,963 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Centerville, SD
  • Local time:03:50 PM

Posted 03 May 2009 - 04:53 PM

var f = document.getElementById("mainframe");//Sets iframe id
No. 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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users