...

View Full Version : Making external website target iframe. Some help please.



jim447
11-20-2010, 02:11 AM
Hello. I have built a basic website that contains an iframe in the middle, called "iframe1". In this iframe I wish to load an external message board from proboards.com. In my code I can easily do this by making a button or hyper-link with the href="http:proboards.com/myforums" and the target="iframe1"

When I do this it will load inside of it the iframe jsut as I want it to. However, my the problem is when you click on the button to login its coded to target "_top" and it opens on the entire page replacing the whole website. If i run firebug (a real time HTML editor). I can easily locate and change the link code to target="iframe1". But How can I write a script in javascript in my webpage code to do this as soon as the iframe has loaded the external messageboard?

I have also been trying things like
javascript:void(document.iframe1.getElementsByTag("a")[5].target="iframe1")

but i have had no luck so far in changing the target without the aid of firebug.

Here is the code that needs to be changed. the target="_top" needs to be altered somehow to target="iframe1" as soon as the frame has finished loading the messageboards.



<p><font size="2">

Welcome Guest. Please <a href="/index.cgi?action=login" target="_top">Login</a> or <a href="/index.cgi?action=register" target="_top">Register</a>.<br/>Nov 19, 2010, 7:23pm

</font><br /></p>


Heres a screenshot that may help, as you can see I have easily changed the target of the link to="iframe1" using firebug, but I need to hardcode a script in my website that does this automatically after the iframe has loaded the forums page.

http://img191.imageshack.us/img191/7264/26796014.jpg

Thanks to for any help.

Old Pedant
11-20-2010, 02:29 AM
You can't. Period. End of discussion.

You can never use JavaScript to modify--or even *read*--anything from any other site.

Can't even do so using AJAX techniques.

It's a MAJOR security feature in browsers--sometimes referred to as "same origin"--so don't expect to find a way around it.

http://en.wikipedia.org/wiki/Same_origin_policy

jim447
11-20-2010, 02:36 AM
You can't. Period. End of discussion.

You can never use JavaScript to modify--or even *read*--anything from any other site.

Can't even do so using AJAX techniques.

It's a MAJOR security feature in browsers--sometimes referred to as "same origin"--so don't expect to find a way around it.

No, but once the site is loaded locally on the client computer u can easily change elements via JavaScript or firebug. such as using the JavaScript:void command. So I am wondering if their is a way this can be automated with a script that loads when the frame on my site loads the external site to alter the local html file links to target my frame instead of _top. I know its possible because i already changed the target to work exactly the way i want it to with firebug. I just need to know how to automate this with a script after the client has been served the website.

Old Pedant
11-20-2010, 02:42 AM
*SIGH* Modifying something ON YOUR MACHINE using Firebug is a *LOT* different than a browser doing something automatically.

Firebug is *INTENDED* for use like this. Intended to allow developers to modify code, inspect values, etc. In any case, no longer is it JavaScript that is in control, it is *YOU* the human being. And if you want to do something to wipe out the hard drive on your computer, or supply your social security number to every site in the world, indeed you should be allowed to do so.

But scripts loaded from the internet should *NEVER* be allowed to do this.

Again:
http://en.wikipedia.org/wiki/Same_origin_policy

By the way, if YOU could do this, what is to stop every hacker site in the world from installing stuff on your computer that, for example, captures all your keystrokes and so knows your passwords and whatever else you type in?

jim447
11-20-2010, 02:47 AM
alrighty, thanks for the information sir. Now if I may rephrase my question. How can I contain an external website within an iframe indefinitely, using any given method, so that when any link is clicked the external site always loads within the frame?

Old Pedant
11-20-2010, 03:15 AM
Same answer. You can't.

If you could, don't you think thousands of other sites would be doing the same thing you are trying to do.

If a site refuses to be framed, it can do so. Simple as that.

You could turn off JavaScript. That would probably stop sites from popping to the top as soon as they load. But all anybody has to do is create a link such as

<a target="_top" href="whatever...">
or a form such as

<form target="_top" action="whatever...">
and zap, out of the iframe as soon as the link is clicked on or the form submitted.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum