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

First I want to create custom tags in HTML
<language>

When i run the HTML page then i want this tag will automatically call JavaScript function.


Thanks in advance

Abhinandan
Posted

Hi,

I am afraid it is not possible to create your own tags in HTML. However, if you want to call a JavaScript in HTML, you shall define the script with ... and then call it for example as a handler of some event.

Regards,
Jan Kucera
   
This is a sample script i use to show a blinking string:


XML
<script type="text/javascript">
    function doBlink() {
           var blink = document.all.tags("alarm") // <-- GET THE TAGS
           for (var i = 0; i < blink.length; i++)
               blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : ""
       }

       function startBlink() {
           if (document.all)
               setInterval("doBlink()", 1000)
       }
         window.onload = startBlink;
   </script>

   ...

   <alarm><asp:Label ID="lblAlert" runat="server" Text="ALARM!"></asp:Label></alarm>
   
You can use onload function lo call the script. However if you like to use Jquery or some other
then you will get other features which will handle it with more efficient.

Here is one of them
http://api.jquery.com/ready/[^]
   
Comments
Abhinandan Mahay 17-Jul-13 7:58am
   
thanks, but how can i create our own custom HTML tag ?
enhzflep 17-Jul-13 23:46pm
   
As you were told in solution #1:
"I am afraid it is not possible to create your own tags in HTML."
Shubhashish_Mandal 18-Jul-13 2:28am
   
Sorry, but I am not saying that you can create a new HTML tag instead you can fulfil the purpose to call the script at the time of loading page,
enhzflep 18-Jul-13 2:43am
   
I've no idea what you're sorry for.

Saying "I am not saying that you can create a new HTML tag" is somewhat redundant. You clearly proposed a method of calling arbitrary code upon page load.

The OP then asked how to create a custom tag.

I pointed him/her back to an answer that was already provided (the first answer, in fact!)
Shubhashish_Mandal 18-Jul-13 2:46am
   
Sorry , Its may mistake.
enhzflep 18-Jul-13 3:03am
   
It's really no problem. :)
Best regards.
enhzflep.

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