Reputation:
I have iframe in the site which acts as an internal browser. I know that frames are generally bad idea but I was not able to find alternative. The question is how to prevent navigation of browser when user clicks a link inside iframe - only iframe has to be redirected, not ALL browser. Sites inside iframe are limited, very simple - mostly static HTML, maybe I can use javascript to add target='iframe_name' to each link inside iframe's HTML if it's possible.. ?
Upvotes: -1
Views: 3723
Reputation: 6094
Yes, you can change all the links with this simple code:
iFrameText = iFrameText.replace(/(<a\s)/ig, "$1target='iframe_name' ")
This, can however create problems if you are having "target" set for some of the links. I think the latter will take the preference.
Upvotes: -1
Reputation: 414086
The normal operation of HTML <a>
tags is alread to replace only the current frame.
Here is a simple, sample page: http://gutfullofbeer.net/frames/able.html
when you click on the links in the box, the frame reloads. Those are just simple <a>
tags.
Upvotes: 3