Forum Moderators: open
when google finds my page it's an orphan,and i'm searching for an javascript that put's the orphan page into my i- frame
any suggestions? <snip> = the site
[edited by: engine at 4:39 pm (utc) on Oct. 5, 2003]
[edit reason] No urls, thanks. See TOS [webmasterworld.com] [/edit]
Have a look at message #21 in our Generic Javascript [webmasterworld.com] thread. It gives an approach to handling orphans from regular framesets - but that approach can easily be adapted to an iframe situation.
[edited by: tedster at 7:39 pm (utc) on Nov. 19, 2003]
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:
passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage
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:
<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('<frameset cols="20%,80%"><frame src="leftnav.html" name="nav"><frame src="' + contentURL + '" name="content"><\/frameset>')
</script>
</html>
btw (i'm not english so i do'nt know how to write this excatly but i'll give it a try) LOVLY FORUM YOU HAVE GOT HERE!
So you need the script to write your iframe element instead, and in the exact spot in your HTML document where you want the iframe code to appear.
The parts of the script inside the parenthesis and between the single quotes are exact text that gets written. The + contentURL + is a variable that you've defined a few lines earlier -- that's the part that writes in the url of the document that was passed. It will stand for something different depending on which orphaned page is activating the script.
document.write('<iframe src="'+ contentURL + 'width="200" height="150" title="your title"></iframe>')
[edited by: tedster at 11:10 pm (utc) on Nov. 19, 2003]