Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Change a css property using javascript onclick
Old 08-06-2006, 06:44 PM Change a css property using javascript onclick
nabil_kadimi's Avatar
Experienced Talker

Posts: 42
Name: nabil
Trades: 0
Hello;

I'm creating a joomla template, and I need the right syntaw for this link

Quote:
<a href="#" onclick=" change the body width property on the css file attached to the current document" >Increase page width</a>
Thank you for your help
nabil_kadimi is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 08-06-2006, 06:54 PM Re: Change a css property using javascript onclick
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
Code:
obj = getElementByTag('body');
obj.style.width = 200px;
I think that's valid didn't test it tho.
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Old 08-07-2006, 04:58 AM Re: Change a css property using javascript onclick
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,383
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
it's getElementsByTagName

setting the width won't work on <body> though

Using getElementById("id") would be better though as getElementsByTagName("div") would be applied to ALL <div> elements in the document
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 08-07-2006, 08:15 AM Re: Change a css property using javascript onclick
saadatshah's Avatar
Extreme Talker

Posts: 215
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Trades: 0
__________________
- -- --- ---- ----- ------ ------- ---------------
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 08-07-2006, 08:46 AM Re: Change a css property using javascript onclick
AliKat's Avatar
Extreme Talker

Latest Blog Post:
Save the Children
Posts: 176
Location: MS
Trades: 0
hehe thanks Chris I don't actually ever use that particular function I always use getElementBy Id().
AliKat is offline
Reply With Quote
View Public Profile Visit AliKat's homepage!
 
Old 08-07-2006, 01:10 PM Re: Change a css property using javascript onclick
Ultra Talker

Posts: 256
Location: Auckland, New Zealand
Trades: 0
I actually prefer using getElementsByTagName, though that would have been due to the lack of support for getElementById at the time.

Why can't you change the width on body?
Cause I know you can.

Is it an IE problem?
If so I didn't know this, but it's quite rare that I would change body width, I usually create fluid sites.

HTML Code:
... in head ...
<script type="text/javascript">
/*<![CDATA[*/
function increaseWidth()
{
  var body = document.getElementsByTagName.item(0);
  body.style.width = 600px // size you want body to increase to
}
/*]]>*/
</script>
... in body (link must go inside a block level element) ...
<a href="#" onclick="javascript:increaseWidth();" >Increase page width</a>
Though Javascript will not be able to read CSS/Browser default styles used (it can read width from the attribute style), but it can grab the size from the browser and use that as a basis for what the size is if you need to work on actually incrementing the size.

Cheers,

MC
__________________
#------------------------------signature---------------------------------------------------------------------------------#
Quote:
I am well recognised for what I don't do than what I do. Chores are just one of those things.

Last edited by mastercomputers; 08-07-2006 at 01:13 PM..
mastercomputers is offline
Reply With Quote
View Public Profile Visit mastercomputers's homepage!
 
Reply     « Reply to Change a css property using javascript onclick
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.85713 seconds with 12 queries