Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

javascript error

  • 21-05-2004 11:37AM
    #1
    Registered Users, Registered Users 2 Posts: 9,448 ✭✭✭


    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, Registered Users 2 Posts: 1,268 ✭✭✭hostyle


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


  • Registered Users, Registered Users 2 Posts: 9,448 ✭✭✭RobertFoster


    cheers :D


Advertisement