document.all["something"].SetAttribute("HREF", "stylesheet.css",0) does not work

Discussion in 'Javascript' started by RC, Oct 3, 2006.

  1. RC

    RC Guest

    Hi,

    I am doing a practice exercise of the book "Developing Web
    Applications with Microsoft Visual Basic.Net." There is also a little
    javascript involved. There is a practice which is all written out in
    the book, so I 'just' have to type it in. Well, it isn't that simple.

    Here is my code:

    <%@ Page Language="vb" AutoEventWireup="false"
    Codebehind="WebForm1.aspx.vb" Inherits="StyleSheetTest.WebForm1"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" content="Microsoft Visual
    Studio .NET 7.1">
    <meta name="CODE_LANGUAGE" content="Visual Basic .NET
    7.1">
    <meta name="vs_defaultClientScript"
    content="JavaScript">
    <meta name="vs_targetSchema"
    content="http://schemas.microsoft.com/intellisense/ie5">
    <link id="ScreenStyle" type="text/css" href="Styles.css"
    rel="stylesheet" media="screen">
    <link id="PrintStyle" type="text/css"
    href="BigStyle.css" rel="stylesheet" media="print">

    <script id="ClientEventHandlerJS" language="jscript">
    function SwitchSheets()
    {
    if (document.all["ScreenStyle"].getAttribute("HREF")
    == "Styles.css")
    //alert("Yes")
    document.all["ScreenStyle"].SetAttribute("HREF", "BigStyle.css",0);
    else
    document.all["ScreenStyle"].SetAttribute("HREF", "Styles.css",0);
    }
    </script>

    </HEAD>
    <body>
    <form id="Form1" method="post" runat="server">
    Test1<br>
    Test2<br>
    <br>
    <br>
    <a onclick="SwitchSheets()" href="#">Click here</a> to
    change the stylesheets.

    </form>
    </body>
    </HTML>



    There are 2 stylesheets, StyleSheet.css and BigStyle.css. One is
    copied from the other. Only the font-size is changed, so there
    couldn't be anything wrong with the copy.

    When the user clicks on 'Click here', the function SwitchSheets should
    switch the stylesheets:
    document.all["ScreenStyle"].SetAttribute("HREF", "BigStyle.css",0);

    The only thing I get is 'error on page'.

    I have IE 6. What am I doing wrong here?
    RC, Oct 3, 2006
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    7
    Views:
    14,716
    John C. Bollinger
    Nov 8, 2004
  2. setAttribute() does not work

    , Aug 22, 2003, in forum: Javascript
    Replies:
    3
    Views:
    151
  3. Shea Martin

    Win32::File::SetAttribute does not work

    Shea Martin, Oct 12, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    279
    Shea Martin
    Oct 13, 2005
  4. Replies:
    2
    Views:
    442
  5. David
    Replies:
    1
    Views:
    300
    David
    Dec 6, 2006
Loading...

Share This Page