Run OnClick command by a url Appened Javascript

madmare
madmare used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Multitechnician
Top Expert 2014
Commented:
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

Author

Commented:
The yourpage.html is a website not belong to me


I cannot add any code to it

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial