javascript - How to open a link inside of iframe when a user trys to open link in a new tab? -
i trying while working before decided post here.
so have navigation bar , each item in navigation bar opens link inside iframe have on home page.
homepage (index.php) has of code
my nav bar:
<ul id="nav"> <li style="width: 20%"> <a href="home.php" target="iframe" id="navbarleft">home</a> </li> <li style="width: 30%"> <a href="saleitems.php" target="iframe" >sale items</a> <ul> <li><a href="saleflyer.php" target="iframe" id="navmid">sale flyer/coupons</a></li> </ul> </li> <li style="width: 30%"> <a href="location.php" target="iframe">store information</a> </li> <li style="width: 20%"> <a href="contact.php" id="navbarright" target="iframe">contact us</a> </li> </ul>
my iframe:
<iframe src="home.php" name="iframe" id = "iframeid" scrolling="no"></iframe>
so default loads home.php , user can browse through links in navigation bar , respective php file link load in iframe.
however if user tried open in new tab, page weird since optimized iframe.
any way if user try open link nav bar in new tab, loads index.php (my homepage) , inside iframe page tried open new tab shows in iframe instead.
you can hang on link onclick, inside code of changing iframe src.
<a href="saleitems.php" onclick="document.getelementbyid('iframeid').src = this.getattribute('href'); return false;" >sale items</a>
Comments
Post a Comment