Jump to content

trigger click onload


dianikol85

Recommended Posts

Hi, i have a link in the php file which i want it to get clicked when the page has been load. I am using jquery. look the code

 

$(document).ready(function(){
$("#pdf").trigger('click');
}); 

 

and this link

 


<a href="http://www.google.com" id="pdf">Google</a>

 

Any suggestions?

Link to comment
Share on other sites

I looked into this just recently, and really didn't find a clean solution. I'm pretty sure the code you posted above won't work the way you anticipate -- you also need a section like this:

 

$('#pdf').click(function(){

...code here...

});

 

One way around it that I found, though, is using jquery to parse the link, return the href value, and use window.location to change the page.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...