Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

javascript inline onclink for href

$
0
0
I have a sharepoint page on which multiple hyperlinks added. due to browser encoding some of them are not redirecting correctly, thus I have to use onclick event for all of them using javascript inline. so while giving hyperlink we can pass URL to inline onclick function. and then we can use windows.locatoin.href in that function.

In content editor webpart its something like :

<p <a href="javascript:onclick=Myfunction('http://www.bing.com');"> bing</a></p>
<p <a href="javascript:onclick=Myfunction('http://www.yahoo.com');"> google</a></p>
<p <a href="javascript:onclick=Myfunction('http://www.facebook.com');"> facebook</a></p

<script type="text/javascript">
MyFunction(url){

$(document).ready(function(){
    
       window.location.href ='url';
    
});

}
</script>


I am missing something, can anyone plz help me out. 
i have added google, bing and facebook for an example

Viewing all articles
Browse latest Browse all 11571

Trending Articles