www.webdeveloper.com
Results 1 to 2 of 2

Thread: Undefined object

  1. #1
    Join Date
    Mar 2008
    Posts
    9

    Undefined object

    code:

    <script type=="text/javascript">

    function show1()
    {
    window.open('abc.aspx');

    }


    function show2()
    {
    window.open('bcd.aspx');
    }

    </script>

    i am calling these functions in

    <asp:Label runat="server" id="label" Text="layout" onclick="show1();"


    <asp:Label runat="server" id="label2" Text="layout" onclick="show2();"


    when click on first label it is calling the function show1,works fine.



    but when i click on 2nd label it showing error 'undefined' is null or not an object.

  2. #2
    Join Date
    Aug 2007
    Posts
    3,767
    For future reference, it's better to show us the generated HTML (i.e. view-Page Source) because that's what JavaScript operates on.

    Firstly, it's <script type="text/javascript">, which shows you haven't validated your HTML, which I advise you to do.

    Secondly, since the segments you've shown us are identical, is there anything important you are leaving out? Preferably show us the form tag, the generated HTML of the input and any important JavaScript. Also, to help see where the problem is, change show2() to this to show is the function being called.
    Code:
    function show2() {
    alert("");
    }
    Also, it's rather silly to have multiple functions doing the same thing, this would be better.
    Code:
    function show(url) {
    window.open(url);
    }
    Code:
    onclick="show('abc.aspx');"
    onclick="show('bcd');"
    Great wit and madness are near allied, and fine a line their bounds divide.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles