Forum Moderators: open

Message Too Old, No Replies

Searching for solution => Orphan iframe

iframe orphan

         

tonycharman

9:41 am on Nov 19, 2003 (gmt 0)

10+ Year Member



Hello, I am trying to seat an externally accessed orphan frame into it's correct frameset.

I have read [netmechanic.com ]
and also [webmasterworld.com ].

I have correctly added the appropriate script into all orphaned pages and created my master.html file, but neither seems to work in practise, the most common error being an empty frame "<html></html>" which I guess would mean that it's not picking up the contentURL.

My (test) page ("master.html") has this within it:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
origURL = parent.document.URL
contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)
document.write('<iframe src="' + contentURL + '" width="200" height="150" title="your title"></iframe>')
</script>

I have also tryied it in a traditional frameset with the following code within the "master.html":

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">
origURL = parent.document.URL contentURL = origURL.substring(origURL.indexOf('?')+1, origURL.length)
document.write('<frameset rows="158,*" cols="*" frameborder="NO" border="0" framespacing="0">
<frame src="top_s.htm" name="topFrame" scrolling="NO" noresize >
<frameset cols="95,*" frameborder="NO" border="0" framespacing="0">
<frame src="left_s.htm" name="leftFrame" scrolling="NO" noresize>
<frame src="' + contentURL + '" name="main">
</frameset></frameset>')
</script>

Which loads the correct frameset nicely, but again where the correct contentURL page should be I just get "<html></html>"

Any thoughts? (please! :o)

[edited by: tedster at 10:48 pm (utc) on Nov. 19, 2003]

tedster

11:15 pm on Nov 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm suspecting the script on the orphaned page itself -- it seems not to be passing a correct query string, and therefore your frameset or iframe is not getting an accurate URL to load in the correct frame.

Does your script on each potentially orphaned page look like this?

passpage = document.URL
if (top.location == self.location)
top.location.href="master.html?" + passpage

And if so, what does the url of the potentially orphaned page look like -- does it, by any chance, have it's own query string or something other oddity?

tonycharman

9:59 am on Nov 20, 2003 (gmt 0)

10+ Year Member



Many thanks for the reply. The orphan pages contain the exact code that you have.

Would the script encounter problems when tested via Dreamweaver locally? I have uploaded to a test site and the script is working nicely within a "standard" frameset.

You can test this via accessing this orphan page: <no URLS, please>. However, the live site views via an iframe. I am trying to get my head around how to incorporate the parent content (which is not a frameset) and have the orphan load within it. Is it as simple as effectively making the index_n.htm the master.html?

[edited by: tedster at 3:13 pm (utc) on Nov. 20, 2003]

tedster

3:41 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can see that the script might fail locally, but would still be accurate when running on the server.

And you are on the right track with an iframe version. Your "master" page will just be a version of the page that holds the iframe, but with this script in place of the original iframe code. As with the conventional frameset solution, you will need one separate master page in addition to your index page.

tonycharman

5:23 pm on Nov 20, 2003 (gmt 0)

10+ Year Member



Bingo :) I saved the iframe "frameset" page as master.html, inserted this in the head:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">

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

</script>


and then inserted this around the iframe code:

<SCRIPT LANGUAGE=JAVASCRIPT TYPE="TEXT/JAVASCRIPT">

document.write('<iframe id=id1 name="main" src="'+ contentURL +'" width="640" scrolling="auto" frameborder="0" marginwidth="0" marginheight="0" height="442" ><a href="index_s.htm">Your Browser does not support iframes = PLEASE CLICK HERE TO VIEW THE SITE =-</a></iframe>')
</script>

It works anyhow - would be interesting to know if you would have done it the same way.
Thanks very much for your help! (what a wonderful forum!)

tedster

5:59 pm on Nov 20, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, that's it. I was assuming that those details were "obvious", but now I can see how they might not be.

Actually, I don't put the script directly in the head, I put it in my external .js file that gets called from the head and then does some other work as well.