Solved

Run OnClick command by a url Appened Javascript

Posted on 2012-04-11
2
163 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to code links for mobile sites that, once clicked, send a call or text to a specified number. For a telephone link (once clicked, calls a number), begin with a normal "<a href=" link tag. For the href, specify…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

829 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