Solved

Run OnClick command by a url Appened Javascript

Posted on 2012-04-11
2
160 Views
Last Modified: 2013-01-02
Hello Experts,

 I have a page wihich containing the following command

<div class="infopopup-vote-button" onclick="voteTo(194)";"> Vote </div>

How do I append to the url a javascript command to click on the button automaticly when the url is executed

Thanks
0
Comment
Question by:madmare
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 37833147
add a parameter in your url like that :

http://www.yourdomain.com/yourpage.html?voteid=194

add this in the head section of yourpage.html :

<script type="text/javascript">
window.onload = function() {
      vote(   gup("voteid")    );
}

function gup( name ) // http://www.netlobo.com/url_query_string_javascript.html
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
</script>

Open in new window

0
 

Author Comment

by:madmare
ID: 37833485
The yourpage.html is a website not belong to me


I cannot add any code to it
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now