Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-15-2009, 11:35 AM   PM User | #1
rhyz
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 13
Thanked 0 Times in 0 Posts
rhyz is an unknown quantity at this point
Unhappy body problems (<body>)

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

Code:
<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

Code:
document.write(pgcursor())
just to see if it is outputing the right things thankyou
rhyz is offline   Reply With Quote
Old 03-16-2009, 08:27 AM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,237
Thanks: 59
Thanked 3,998 Times in 3,967 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
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:
Code:
<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>
...
Old Pedant is offline   Reply With Quote
Users who have thanked Old Pedant for this post:
rhyz (03-17-2009)
Old 03-17-2009, 12:01 PM   PM User | #3
rhyz
New Coder

 
Join Date: Mar 2009
Posts: 23
Thanks: 13
Thanked 0 Times in 0 Posts
rhyz is an unknown quantity at this point
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

Last edited by rhyz; 03-17-2009 at 12:07 PM..
rhyz is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:46 PM.


Advertisement
Log in to turn off these ads.