Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

javascript error

Options
  • 21-05-2004 11:37am
    #1
    Registered Users Posts: 9,196 ✭✭✭


    hey, I've an error on the following code:
    <html>
    <head>
    <title>testing javascript!</title>
    <script language=JavaScript>
    <!--
    function URL()
    {
    	var url=prompt("Enter the URL","http://");
    	var linkname=prompt("Enter the name","");
    
    	var current=document.test.display.value;
    
    	document.test.display.value=current+"<a href="+url+">"+linkname+"</a>";
    }
    function IMG()
    {
    	var url=prompt("Enter the URL","http://");
    
    	var current=document.test.display.value;
    	
    	document.test.display.value=current+"<img src="+url+">";
    }
    //-->
    </script>
    </head>
    <body>
    <form name=test>
    <input type=button value="URL" onclick="URL()">  //when run, this is the line with the error
    <input type=button value="IMG" onclick="IMG()"><br>
    <textarea cols=30 rows=10 name=display></textarea>
    </form>
    </body>
    </html>
    

    The URL function doesn't work, but strangely enough, the IMG one does and they're a variation on one another...

    Can anyone see something blatently obvious??? I'm better at debugging PHP than JavaScript :dunno:


Comments

  • Closed Accounts Posts: 1,651 ✭✭✭Enygma


    If you change the name of the URL() function to something like doUrl() it will work. This is because there's a URL object in Javascript.


  • Registered Users Posts: 1,268 ✭✭✭hostyle


    URL() appears to be a reserved name. Try calling the function a different name.


  • Registered Users Posts: 9,196 ✭✭✭RobertFoster


    cheers :D


Advertisement