Is it possible to trigger the javascript function of an anchor tag during page load?
Here is my fiddle
<a id="WebTree" href="javascript:alert('testing')">click me</a>
$(document).ready(function(){
$('#WebTree').trigger('click');
//$('#WebTree').click();
// after the page load I'm expecting to see the alert but it's not working
});
I’m expecting to see an alert after the page is loaded but I’m not
EDIT
Ok here’s simple explanation why I’m asking this question.
Here is the original link which was dynamically generated by sharepoint.
<A id=ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewn1 href="javascript:TreeView_PopulateNode(ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeView_Data,1,ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewn1,ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewt1,ctl00_PlaceHolderLeftNavBar_ctl01_WebTreeViewt1i,' ','TaxonomyMetadata','Pages\\TaxonomyMetadata','t','30:FieldNameNode:e305128c-217b-47b4-81b9-db0c1e59f98f:3b529925-3610-485a-9133-bc958f7ab28e:dbf365da-565b-41ca-966d-f9bf29d9b2cf:30|ListNode|e305128c-217b-47b4-81b9-db0c1e59f98f|3b529925-3610-485a-9133-bc958f7ab28e|ea06a686-46c5-4470-a1ab-4fe4341589c8','tt')">
<IMG style="BORDER-RIGHT-WIDTH: 0px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" alt="Expand TaxonomyMetadata" src="/_layouts/images/MDNCollapsed.png">
</A>
Bottom line I have no control of the anchor tag.
How about: