SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    typeof window == "object" in Netscape

    Hi everyone,

    I've got an older piece of code that was written specifically for IE that works great. In short, we've got two buttons (pending and approved) and a window below them. When each button is pressed, the appropriate list is populated in the window. However, we're also changing the label in a line of text to the appropriate category.

    IE works perfectly, but Netscape changes the list, but not the label. When I run it with alerts, typeof window.lblFilter comes back as "undefined" or "string" in Netscape, not "object" as I'm hoping form.

    Any suggestions are much appreciated! Thanks, Julia

    Code:
    function SetListTitle(sList){
            if(navigator.appName=="Microsoft Internet Explorer"){
    	if(typeof window.lblFilter == "object"){
    		if(sList == "Pending"){
    	window.lblFilter.innerHTML='<font color=red>PENDING</font>';
    	}else{
    	window.lblFilter.innerHTML='<font color=blue>Approved</font>';
    	}
    			}
    		}
            if(navigator.appName=="Netscape"){
    	if(typeof window.lblFilter == "undefined"){
    		if(sList == "Pending"){
    	window.lblFilter.innerHTML='<font color=red>PENDING</font>';
    	}else{
    	window.lblFilter.innerHTML='<font color=blue>Approved</font>';
    	}
    			}
    		}
    }
    Code:
    <table>
    <tr>
        <td align="right" colspan="4">
        <p align="center">
    You are now viewing the Distributor Registration <u><b><label name="lblFilter" id="lblFilter"><font color=red>PENDING</font></label></b></u> List
        </td>
    </tr>
    <tr>
        <td colspan="4">
        <iframe name="DistList" id="DistList" width="520" height="172" src="DistList.asp?ID=<%=sDistID%>&Filter=<%Session("DistListFilt")%>" scrolling="yes"></iframe>
        </td>
    </tr>
        <%End If%>
      </table>
    
    <%
    If Session("DistListFilt") = "Approved" Then
    	Response.Write "<script>SetListTitle('Approved')</script>"	
    Else
    	Response.Write "<script>SetListTitle('Pending')</script>"
    End If
    %>

  2. #2
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What Netscape version would that be? And what does lblFilter point to?

  3. #3
    SitePoint Member
    Join Date
    Jun 2006
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for replying! I'm testing with Netscape 8. lblfilter is the label name and id (<label name="lblFilter" id="lblFilter">, it's in the fifth line of the second block of code).

    Thanks!

  4. #4
    SitePoint Wizard Pepejeria's Avatar
    Join Date
    Jan 2005
    Location
    Too far up north
    Posts
    1,566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use document.getElementById("id_of_element") to access elements, works in all modern browsers, so there is no need to check for what browser it is. Your script will not work for many other browser. With no real point whatsoever.

    document.getElementById() returns null if the element is not found


Bookmarks

Posting Permissions

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