Click here to Skip to main content
15,888,300 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

How to notice when any event(button click, click on a link etc) occurs after page load in javascript? I mean, I need to take some action whenever
any event rises after page load...

Basically I want to find "video" tag is there in a given page or not as soon as it loads. But there may be a possibility that one can create a video tag based on some events(such as button click or click on a link etc). So I want to notify if any such event occurs, so that I can call my custom code to search for video tag...


Thanks.....
Posted
Updated 23-Jun-10 20:43pm
v2
Comments
Sandeep Mewara 23-Jun-10 11:01am    
You are not clear on what you are trying to do. If any event raised page load, it will go to that event method. What are you looking for exactly? Explain more.
vinodkalanji 24-Jun-10 2:39am    
Hi Sandeep, Basically I want to find "video" tag is there in a given page or not as soon as it loads. But there may be a possibility that one can create a video tag based on some events(such as button click or click on a link etc). So I want to notify if any such event occurs, so that I can call my custom code to search for video tag...


Thanks......

1 solution

You can do one thing.

When any event will be fired, on Page Load you can identify that event is fired by which component. Once checked you can register javascript (with calling a function) at that time and then do apply search for your tag.

Thanks.
 
Share this answer
 
Comments
vinodkalanji 24-Jun-10 8:46am    
Hi Mehul,
Thanks...But the events(button click, click on a link etc) will happen after everything on the page is already rendered. So it wont't be helpful to me right?

Thanks....
Mehul M Thakkar 25-Jun-10 0:48am    
Hi Vinod,

When you want to find, at initial load of page or after any event? As you said you want on particular event. So what you can do is, you can write some JS function to find your "Video" tab on HTML side. You can call this function with registering JS on Page_Load event with checking IsPostback.
vinodkalanji 25-Jun-10 1:56am    
Hi Mehul,
I have the code that finds the video tags in a page. But I don't know how to notify an event that occurred after page load. For example imagine I have a webpage that has a button. After webpage is loaded you can see the button. 'Video' tag scenario hasn't come yet but page has completed loading. Now if I click the button which will create a video tag (using CreateElement("video")), a video tag is added to the page which was unknown during page load. What I all have to do is get notified whenever such events occurs so that by that time I can call my function to search for the video tag.
Thanks.........
Mehul M Thakkar 25-Jun-10 2:56am    
As you said, on click of button "video" tag will be generated with CreateElement("video"). Where you have written this code? If you are only going to create video tag then why you want to search it?
vinodkalanji 25-Jun-10 5:50am    
Hey Mehul,
That was just an example. I am not going to insert(create) the video tag. If any webpage I open through browser(for example youtube) that may have some button which inserts a video tag on click of it. Hope you got what I am trying to say :) :)

Thanks....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900