...

View Full Version : body problems (<body>)



rhyz
03-15-2009, 12:35 PM
HI !!! 2nd thread

I was very happy with the reply i got in the last post, it worked thankyou !!!

now my next problem!!!

I have been trying for the last couple of days and havent solved it yet.

I have a cookie that stores the name of a cursor. the script writes what i need and all i have to do it get it working in the body tag



<script type="text/javascript" src="cookie.js">
</script>

<script type="text/javascript">

var bc = "'bc'"

function pgcursor() {
cursor=getCookie('cursor');
if (cursor!=null && cursor!="")
return 'document.getElementById('+bc+').style="cursor:url('+cursor+');"'
}
document.write(pgcursor())
</script>

<body id="bc" name="bc" style="cursor:url();">


basically i need to output the cookie in the cursor url part of the body tag

and in the script i have



document.write(pgcursor())


just to see if it is outputing the right things :) thankyou

Old Pedant
03-16-2009, 09:27 AM
Various errors:
(1) var bc = "'bc'"
No. Just
var bc = "bc";
But you shouldn't use an ID on the <BODY> tag in any case.

(2) You are doing
document.write(pgcursor())
*before* the <BODY> tag! When you do document.write before the <BODY>, the results can be unexpected. Most often, you will find that *effectively* you have moved the <BODY> tag to the point of the write.

(3) Why not just use alert( ) to find out the value for debugging purposes?

(4) You can't change the entire style of an element as you are trying to do. You can only change one characteristic of the style at a time.

(5) Your initial style for the body's cursor is illegal, since you specified a url but then omitted any actual url.

So:


<script type="text/javascript" src="cookie.js"></script>
<script type="text/javascript">

function pgcursor() {
cursor=getCookie('cursor');
if (cursor!=null && cursor!="")
{
alert("Value of cursor is ::" + cursor + "::");
// document.body.style.cursor="url("+cursor+ ")";
}
}
</script>

<body>
...

rhyz
03-17-2009, 01:01 PM
Thanks but when i run your script i get no errors but the mouse still does not display and nor does the alert ???

O my i so stupid sorry script works fine im such a idiot so so sorry thankyou so much :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum