I currently have the below script that grabs the links inside the div (scrollbox) and as you can see it is set to have the links open in a new window. I need to have them open in the div they come from within the original page. Can I do this with this script? If not what should I be using?
function Init()
{
// Grab the appropriate div
theDiv = document.getElementById('scrollbox');
// Grab all of the links inside the div
links = theDiv.getElementsByTagName('a');
// Loop through those links and attach the target attribute
for (var i=0, len=links.length; i < len; i++) {
// the _blank will make the link open in new window
links[i].setAttribute('开发者_如何学运维target','_blank');
}
}
window.onload = Init;
Thanks very much for the help!
If you want to load the pages the links refers to, but in the current page, you should consider using the <iframe>
tag.
But maybe i don't understand fully what you need
Look into JQuery's load function
Something like this should work:
<div id="webpageContainer"></div>
$( "#link" ).click( function()
{
$( "#webpageContainer" ).load( $(this).attr( 'href' ));
});
精彩评论