SEO | Link Popularity | Search Engine Consulting | SEO Tutorial | SEO Tools | SEO Forum
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-22-2006, 08:37 PM
nacho's Avatar
nacho nacho is offline
SEO Junior
 
Join Date: Aug 2005
Location: Spain
Posts: 18 nacho is on a distinguished road
certain composed attributes

Code:
var	message=document.createElement('div');
	message.style.position="absolute";
	message.style.width="200";
	message.style.height="70";		
	message.style.left=200;
	message.style.top=50;	
	message.innerHTML='hello';
document.getElementsByTagName('body').item(0).appe  ndChild(mensaje);

In this code I show a "hello" message.
I am not able, however, to edit certain composed attributes.
Code:
	message.style.background-color="#0066FF";
	message.style.z-index=2;

This two sentences give error.
How can I bypass the problem?
Thanks a lot.
__________________
Reply With Quote
  #2  
Old 04-03-2006, 01:37 AM
BSolveIT's Avatar
BSolveIT BSolveIT is offline
SEO
 
Join Date: May 2005
Location: England, UK
Posts: 621 BSolveIT has a spectacular aura aboutBSolveIT has a spectacular aura about
Send a message via MSN to BSolveIT
Hi Nacho

Well, you've got a couple of choices I guess:

1) Publicly declare 'message' so that it can be referenced outside of the function that created it. You could do that simple by declaring it before the start of the function.

e.g.
Code:
<SCRIPT LANGUAGE=javascript>
<!--
var	message=document.createElement('div');
function creatediv()
{
		message.style.position="absolute";
		message.style.width=200;
		message.style.height=70;		
		message.style.left=200;
		message.style.top=50;	
		message.innerHTML='hello';
		document.getElementsByTagName('body').item(0).appe  ndChild(message);
}
//-->
</SCRIPT>

or (and this would be my preference)

2) Assign an id to the div so that you can refence it from anywhere.

e.g.
Code:
<SCRIPT LANGUAGE=javascript>
<!--
function creatediv()
{
	var	message=document.createElement('div');
	message.style.position="absolute";
	message.style.width=200;
	message.style.height=70;		
	message.style.left=200;
	message.style.top=50;	
	message.innerHTML='hello';
	message.id = "mydiv";
	document.getElementsByTagName('body').item(0).appe  ndChild(message);
}
//-->
</SCRIPT>


Then, when you want to reference the div, use it's id 'mydiv'.

Lastly, the code you pasted above for changing the background colour and the z-Index is wrong. If you were using my preferred solution above (2), it would be:

mydiv.style.backgroundColor = "#0066FF"
mydiv.style.zIndex="2"

That pretty much covers it.

Reply With Quote
Reply


Thread Tools
Display Modes 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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


Login/Register
User Name
Password
Remember Me?

Forum Links
Forum Home
SEO Forum
Internet Marketing Forum
Web Design Forum
Web Hosting Forum
Programming Forum
SEO Chat

Quick Links
Forum Home
New Posts
Mark Forums Read
Open Buddy List
User Control Panel
Edit Avatar
Edit Profile
Edit Options
Miscellaneous
Subscribed Threads
My Profile

Search Forums

Advanced Search
All times are GMT -8. The time now is 02:35 AM.


Powered by: vBulletin Version 3.0.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.