1
I’m looking to improve the way pages load from my project.
In this project I’m using jquery
to load the page into a box when I click on one of the links I make available. In this script it uses the link that is in the href
to load the page.
Only that I would like (if possible) to 'make up' this link with the onclick
. I want to make sure that if the person directly clicks on the link to load the page in the box that should be loaded, only I also want if the person wants to open that link in a new tab they can open, only a different page.
That is, in the href
i want to use a link where if the person clicks to open the page in new tab will open for example the page a.php, now if the person right click on the link load the page b.php via jquery
inside the box.
The script that jquery
what use for loading pages inside the box is:
$(document).ready(function(){
$('.postss a').live('click',function(){
$('#conteudo').load($(this).attr('href'));
return false;
});
});
I understood the line of reasoning. I just did not use out-href, I used an id, so replace attr('href') by attr('id'). And in the link I added the id, ai was <a href="a. php" id="b. php">Link</a>
– ivan veloso
This out-href attribute is not standard HTML, so it can be "created" for your needs, I think it’s risky to use an existing attribute for a different context, mainly id, but if you’ve got the right reasoning
– Ademir Mazer Jr - Nuno
As @Jader commented in his reply, change the line where you take the element, instead of using . live use . on:
$('.postss a').on('click', null, function(){
– Ademir Mazer Jr - Nuno