darkfreaks Posted October 26, 2009 Share Posted October 26, 2009 okay so what i am doing is using a modalbox popup for my application. however i want to change the stylesheet color meaning i would have to use more than one CSS stylesheet. the tricky part is coming up with a way to apply the changes so that it works without closing the modalbox popup when you click on the link it will change the theme according to the color link. Quote Link to comment Share on other sites More sharing options...
seanlim Posted October 27, 2009 Share Posted October 27, 2009 i think you can just change the href of the stylesheet dynamically within the modal dialog. The new stylesheet should load and replace the original. Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 27, 2009 Author Share Posted October 27, 2009 thank you i will look at the modalbox wiki on google i will mark it as solved for now Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 27, 2009 Author Share Posted October 27, 2009 okay i found a function that will switch the stylesheet but it wont work with modal as it currently is. it will just make the page reload with the default modal stylesheet. code: <script type="text/javascript"> function changeActiveStyleSheet(previous, new) { if(document.styleSheets) { for (var StyleSheetIterator = 0; StyleSheetIterator < document.styleSheets.length; StyleSheetIterator++) { if(document.styleSheets[styleSheetIterator].title == previous) { document.styleSheets[styleSheetIterator].disabled = true; }; if(document.styleSheets[styleSheetIterator].title == new) { document.styleSheets[styleSheetIterator].disabled = false; }; }; }; } </script> <script type="text/javascript" src="ajax.js"></script> <link rel="stylesheet" href="modalbox.css" title="Original Purple" type="text/css" media="screen" /> <link rel="stylesheet" href="orange.css" title="Orange Flavor" type="text/css" media="screen" /> <div id="links"><a href="" onclick="changeActiveStyleSheet('Orange Flavor', 'Original Purple');">Original Purple</a>|<a href="" onclick="changeActiveStyleSheet('Original Purple', 'Orange Flavor');">Orange Flavor</a></div> Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 27, 2009 Author Share Posted October 27, 2009 nevermind that function just makes a radiobox a different color, but how would i do that in modalbox to make the whole style a different color Quote Link to comment Share on other sites More sharing options...
darkfreaks Posted October 31, 2009 Author Share Posted October 31, 2009 if anyone knows how i would make the modalbox reload on click with a different stylesheet please let me know how i would do this Quote Link to comment Share on other sites More sharing options...
seanlim Posted November 1, 2009 Share Posted November 1, 2009 You probably will have to "return false" somewhere in your function or in your onclick event, because the link is still redirecting your to href="" after the onclick event is finished. "return false" will override that action. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.