BleepingComputer.com: [URGENT] Open links in content box

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.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[URGENT] Open links in content box Help me please :D

#1 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

  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!
...

#2 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

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.
"Take the risk of thinking for yourself, much more happiness, truth, beauty, and wisdom will come to you that way" - Christopher Hitchens

#3 User is offline   Super Panda 

  • Forum Regular
  • PipPipPip
  • Find Topics
  • Group: Members
  • Posts: 269
  • Joined: 23-April 08
  • Gender:Male
  • Location:Leicester

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 User is offline   groovicus 

  • Hail Groovicus!
  • PipPipPipPipPipPip
  • Find Topics
  • Group: Moderator
  • Posts: 9,522
  • Joined: 05-June 04
  • Gender:Male
  • Location:Centerville, SD

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.
"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
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users