iframe changing main page jquery or html
i have a iframe and it is linked to pictures.html and on this page i have links but when i click the links it changes the ifame page is there anyway i can change the main page using jquery or something?开发者_开发百科
You can use target="_top"
to change the top page's location:
<a href="page.html" target="_top">change main page location</a>
or _parent
to change parent page's location
<a href="page.html" target="_parent">change parent page location</a>
you don't need jQuery, you can do this regular javascript.
in your iFrame:
<a href="#" onclick='window.parent.location="www.newurl.com"' />
you could have the links on pictures.html have onclick events that send the location to the parent window.
$(".link").click(function() {
window.parent.location = $(this).attr('href');
return false;
});
you can have the link open in a new window or tab....
The HTML to open a new window:
<a href=”http://sitename.com” target="_blank">Link text here</a>
精彩评论