This is what the link looks like on page 1:
<li id="click1">
<a href="products.htm#test4Handle1">TNT Cable System</a>
</li>`
This is what I want to trigger on page 2:
<a name="test4Handle1">
<button onclick="$('#test4Handle1').click()">TNT Cable System</button>
</a>
my attempt at jquery
$("test4Handle1").observe('domready',function() {
document.getElementById("test4Handle1").click();
});
What page should have the javascript page 1 or 2?
Check if this helps you. Following is one example I got working
Here is Page1.html
<!DOCTYPE html>
<html>
<head>
<title>Page1</title>
</head>
<body>
<h2>Page1</h2>
<a href="page2.html?event=true">Click here to go on page2</a>
</body>
</html>
And here Page2.html
<!DOCTYPE HTML>
<html>
<head>
<title>Page2</title>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js" >
</script>
<script type="text/javascript">
$(function() {
var prevURL = (window.location.search).contains("event=true");
if(prevURL == true)
$("#btn_click").click();
else
alert("Not proper prev page");
});
</script>
</head>
<body>
<h2>Page2</h2>
<a href="page1.html">Click here to go on page1</a>
<input type="button" id="btn_click" value="Test Button Click"/>
<script>
$("#btn_click").click(
function() {
alert("Button CLicked From jQuery");
});
</script>
</body>
</html>
On Page 2, paste this code
$(document).ready(function(){
if(window.location.hash == "#test4Handle1"){
document.getElementById("test4Handle1").click();
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With