简体   繁体   中英

How to return the onclick function is result to href in javascript?

Now, my code to share on twitter looks like this :

<span class='st_twitter_large' st_via="mediajobscom" st_url="" onclick="window.location.href=myURL;" displayText='Tweet'></span>

And the script i use :

<script>
var myURL = document.URL+"&featuredid={$listing.Title}&featured=true";                    
</script>  

When i click on the share button now, it reloads the page and it adds my parameters featuredid and featured.I need to return this value to the st_url="" so that i can share the new resulted link which contains the parameters.

Thanks a lot for your help! Hamza

var myURL = document.URL+"&featuredid={$listing.Title}&featured=true";

使用javascript替换st_twitter_large类中的st_url属性:

document.getElementsByClassName("st_twitter_large")[0].setAttribute("st_url", myURL);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM