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

R

RC

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?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top