button which change the background
3 posters
Page 1 of 1
button which change the background
Hello, i have this code
which change the background from black to red when i click it, but i want when i click this button and background becomes red , i want remain red and when I recharge the forum.
- Code:
<input type="button"
value="Pattern1"
onclick="document.body.style.cssText+=';background: red;background-repeat: no-repeat;';">
which change the background from black to red when i click it, but i want when i click this button and background becomes red , i want remain red and when I recharge the forum.
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Re: button which change the background
Try setting a cookie with JS. Also, use unobstrusive JavaScript. As in, all click elements are specified in a script and not with onclick="" attributes.
Then, in another JavaScript file.
Hope this helped.
- Code:
jQuery(document).ready(function(){
jQuery('input[value="Pattern1"]').click(function(e){
e.preventDefault();
jQuery(document.body).css({
'background-color' : '#ff0000',
'background-repeat' : 'no-repeat'
});
document.cookie = "color=#ff0000";
});
Then, in another JavaScript file.
- Code:
jQuery(document).ready(function(){
var myGetCookie = document.cookie.replace(/(?:(?:^|.*;\s*)color\s*\=\s*([^;]*).*$)|^.*$/,"$1");
var testRegex = /#[abcdefABCDEF0-9]{6}/;
if(testRegex.test(myGetCookie)) {
jQuery(document.body).css({
'background-color' : myGetCookie,
'background-repeat' : 'no-repeat'
});
}
});
Hope this helped.
Last edited by Ultron's Vision on June 21st 2013, 1:50 pm; edited 1 time in total
Re: button which change the background
it doesn't work
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Re: button which change the background
I edited my code a bit, my RegExp only matched numbers and not hexadecimals, but it should be fixed now.
Re: button which change the background
what i must write in php ?
doesn't work again
doesn't work again
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Re: button which change the background
Who said anything about PHP? O_o
You're using a forumotion-hosted forum, right?
If you can use PHP, this code would be written totally different (and you wouldn't be using a forumotion forum).
You're using a forumotion-hosted forum, right?
If you can use PHP, this code would be written totally different (and you wouldn't be using a forumotion forum).
Re: button which change the background
My friend, i want create one button which it can change the color of background etc.
i have created this button with "onclick" but when i do recharge the changes Leave...
I meant the templates when i said "php".
i have created this button with "onclick" but when i do recharge the changes Leave...
I meant the templates when i said "php".
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Re: button which change the background
Did you add the JavaScript I provided under Admin Panel -> Modules -> HTML & JavaScript -> JavaScript pages management -> Create a new JavaScript?
Otherwise, I'll provide some more code later on. You might need to enable cookies in your browser.
Otherwise, I'll provide some more code later on. You might need to enable cookies in your browser.
Re: button which change the background
i add this code. but nothing.
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Re: button which change the background
Please don't double/triple post. Your post need to be separated by 24 hours before bumping, replying or adding more information. Please use the edit button instead!
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Re: button which change the background
I shall perform some tests with the code and then I'll get back to you, okay?
Re: button which change the background
ok my friend
sample123- New Member
- Posts : 13
Reputation : 1
Language : English
Similar topics
» Button change background etc
» Please change the ugly background for like button
» I've changed every button on the navbar BUT THE PM BUTTON WON'T CHANGE!!! Help please?
» Is it possible to place the chatbox on a different button? And also, can I change the button (portal) to home?
» How do I change background Move logo on to the middle and change letter colour!
» Please change the ugly background for like button
» I've changed every button on the navbar BUT THE PM BUTTON WON'T CHANGE!!! Help please?
» Is it possible to place the chatbox on a different button? And also, can I change the button (portal) to home?
» How do I change background Move logo on to the middle and change letter colour!
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum