When clicking on a hyperlink jquery should work and the page should not navigate - jquery
I am displaying a text for example let us consider the text as "SOF".
When i clicking on the "SOF" text i show that specific site in my site with in a iframe.
This case is working fine...
But my problem is when i click on the "SOF" text iframe is loading as well as the page is also totally navigating to the same page. This should not happen. I given my code here. What is the way to prevent from redirecting the whole site.
EDIT :
This URL is working fine : http://www.oercommons.org/browse/collection/free-ed-gov
This URL is not working : h开发者_JS百科ttp://www.merlot.org/merlot/viewMaterial.htm?id=79516
What may be the issue.. :-(
Note : I know there is no need for jquery to displaying the site in an iframe. But in my case some times i will display html, pdf etc... So I am in need to use jquery. :-)
var xhr = null;
//by default set the element properties
var preview_on = true;
Drupal.behaviors.previewOverview = function(context) {
//show preview on mouse over
$('.links a').click(function(e) {
e.preventDefault();
if (xhr && xhr.readyState != 4) {
//if previous ajax is working then cancel it
xhr.abort();
//$('#right-sidebar-right').html('Preview Panel.');
}
if (preview_on) {
curLink = this;
targetLink = this.href;
data = '<div><a href='+ targetLink +' target="_blank">View Original Page</a></div>' + '<iframe src="' + targetLink + '" width="100%" height="500px"></iframe>';
// To display the data in selected area.
$('#right-sidebar-right').html(data);
}
} else {
$('#right-sidebar-right').html('Turn on preview mode to view.');
}
});
Or, you could also do..
<a href="http://www.google.com" >google</a>
$('a').click(function(e){
alert("do something");
e.preventDefault();
});
Try tweaking an example here..
精彩评论