Links in iframe will open on the same window by default, but specifying target on base tag we can make all links inside iframe to open in same / new window.

In normal cases setting  target=_parent  target=_blank  will make links open on same / new window. It's just not elegant when you have more links in iframe content. So we can make use of <base> tag for this purpose.

By setting target attribute to _parent / _blank we can make all links to open in same / new window in iframe.

Example:
<html>
<head>
<base target='_parent' />
</head>
<body>
<a href='http://webdevelopmentscripts.com'>web development scripts</a>
</body>
</html>

Links in iframe will open on the same window by default, but specifying target on base tag we can make all links inside iframe to open in same / new window.
 


Comments (1)
  1. Image
    Jae - Reply

    September 27, 2017

    Thank you! This little code was a life-saver for me. I was using the script below, it would do the trick but would interfere with other functions on my website. [site would not accept script] ---------------------- So thanks a ton:)

Leave a Comment

loader Posting your comment...