Forum Moderators: open
Ideally I'd like to do this with a 'body onload' command or something like that but am thick as two short planks when it comes to JS, still getting to grips with CSS and HTML I'm afraid!
The problem with "src" is that whilst it loads in the chosen page well enough, it's impossible to direct someone to a certain section of the site (via a link in an e-mail for example) without having the page named after the "src" attribute load up instead.
I have absolutely no doubt this question shows what a novice I am but all help appreciated!
You are correct that this will require javascript. So you will need your thinking cap for a bit, but this is not the most complex javascript by a largemeasure - it's well with the grasp of us mere mortals (trust me, I'm no js master, either.)
Any html document that is displayed within a frame or an iframe can (and should, IMO) also contain script that inserts it into its parent page in the event that someone comes there directly -- an "orphan"display of a page that is intended to have a "parent." Search engines index frame documents a lot and send people directly to the orphan all the time - and with such a script installed, you can justr giver someone the url of the iframed page and the script will take care of inserting it into its parent page.
We have an example of how to do this with a regular frame page - but you can adapt the idea for an iframe page with just a few changes:
See Message #21 on:
[webmasterworld.com...]
Also note that another member, visuale, is working on the same issue right now.
[webmasterworld.com...]
I think I might need leading by the hand on this! I've attemped to run the code that Visuale posted but all I get is the main index page inside the iframe.
I understand the idea of what's going on with the 'master.html' page but I don't understand the code enough to spot any mistakes I'm making.
Message #21 on:
[webmasterworld.com...]
There is a lot of explanation there about what the scripts are doing. Yes, I realize this may be a bit of a stretch for you...but you have expressed a sophisticated need and that takes a bit of a sophisticated solution.
That's how we all grow our skills, I think - and there is definitely help available here on the forums. We won't just do the work for you, but we'll be glad to help you through some sticky spots.
Here we go...
<script language="javascript">
if (top.location.href == document.location.href)
{
top.location.href = 'PageWithiframe.htm' ;
}
else
{
}
</script>
This script first checks to see if the page the code is on, is the same as the file name in the address bar.
If the is true, it means that your page isn't being viewed in the iframe, and so sends the user to "PageWithiframe.htm". In the code you should replace this with the name of the page with the iframe (eg index.htm). If the statement is false, it does nothing.
Hope this helps,
Chris
P.S. This means you can link to the iframe page in the email, and then it will redirect the user
Message #21 on:
[webmasterworld.com...]