/    Sign up×
Community /Pin to ProfileBookmark

Linking into iFrames

I hope whoever can help me out here is prepared to read a bit ?

THE MAIN IDEA
You can add ANY page’s name to the end of a URL [after a “?”] Then you only need ONE frameset page to catch an indefinite number of orphan pages and put them into their frameset. This method offer very easy maintenance, especially when there are lots and lots of possible orphans for one frameset.

THE CODE
Call this javascript code from the HEAD section of each child page. The code creates a variable from the URL of the page, and then passes that variable in the new location’s URL. This means a “master” frameset can load this exact page in the content section:

[CODE]
passpage = document.URL
if (top.location == self.location)
top.location.href=”master.html?” + passpage[/CODE]

Then create just one “master.html” page. It holds the JavaScript code to decipher whatever URL is passed after the “?” and it writes that page into the content frame:

[CODE]
<html>
<head>
<title>Master Frameset</title>
</head>

<script language=”JavaScript” type=”text/javascript”>

origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf(‘?’)+1, origURL.length)

document.write(‘<iframe src=”home.php” name=”nav”><frame src=”‘ + contentURL + ‘” name=”content”></iframe>’)

</script>
</html>[/CODE]

So, as you can see [If you have used iFrames before] you can’t link to a specific page through the iFrame. This script is supposed to let you do this, but I am having problems with it.

MY PROBLEM:
Here is my website for refrences:
[url]www.visualevolution.net/sglaw[/url]

Check out:
[url]http://www.visualevolution.net/sglaw/master.html?aboutus.php[/url]

As you can see, the javascript has pulled this page into an iFrame, but not the main iFrame in index.html.

Any ideas as to why this is happening?

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceMar 28.2005 — The problem is that you're using [b]document.URL[/b]. This property will not have the query/search string attached to it. You have to use the [b]location.href[/b] property to get the entire URL. However, if you just want the query/search string attachment, you can use the [b]location.search[/b] property instead.
Copy linkTweet thisAlerts:
@js_prof_consMar 28.2005 — The problem is that you're using [b]document.URL[/b]. This property will not have the query/search string attached to it. You have to use the [b]location.href[/b] property to get the entire URL. However, if you just want the query/search string attachment, you can use the [b]location.search[/b] property instead.[/QUOTE]Be careful with all of this. For some odd reason, there will be differences depending on how you reference it. This [url=http://www.quirksmode.org/js/iframe.html]page[/url] does a good job. And also points out that you are correct ?
Copy linkTweet thisAlerts:
@the_treeMar 28.2005 — Personaly, I would do this server side, just for neatness.[code=php]<?php
if( isset($_GET['p']) )
{$page = $_GET['p'];}
else
{$page = 'default.htm';}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<html lang="en">
<head>
</head>
<framset rows="50px,*">
<frame name="title" src="titlebar.htm">
<frame name="page" src="<? echo $page; ?>">
<noframes>
<p>We were <em>going</em> to display <a href="<? echo $page; ?>">this page</a>.</p>
</noframes>
</frameset>
</html>[/code]
[i]Edit[/i]: Whoops, you wanted an iframe. Oh well, the same principle applies.
×

Success!

Help @vevolution spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.11,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...