|
Bangladeshi Softwares
|
| Home - Download - Codes & Tutorials - Bangla IT Bibhag - Mobile - About Me |
Dynamically change or replace stylesheets in Internet Explorer
You can change the stylesheets dynamically in Internet Explorer. Open a text editor and enter the code below:
<head>
<link rel="stylesheet" href="" type="text/css">
<script language="javascript" type="text/javascript">
<!--
/*
* Author: Ahsanul Haque Shovon
* Email: ahsanul.haque.shovon@gmail.com / ahsanul_haque_shovon@yahoo.com
* Web: http://shovon.110mb.com
*/
/*****************************************
* FUNCTION: changeStyleSheet(arg)
* ARGUMENT: Takes a number (1 to 4)
* DESCRIPTION: Used to change or replace
* the stylesheet attached to the page
* with the <LINK rel='?' href='?'> tag.
******************************************/
function changeStyleSheet(s)
{
var msg = "Using stylesheet: ";
if(s >= 1 && s <= 4)
{
if(document.styleSheets(0).href != null)
{
document.styleSheets(0).href = "Style-0" + s + ".css";
document.all.spn.innerHTML = msg + document.styleSheets(0).href;
}
}
else
{
var err = "Not a valid option! Using the current stylesheet.";
document.all.spn.innerHTML = "<font color=\"#C00000\">" + err
+ "</font>";
}
}
//-->
</script>
</head>
<body>
<form name="form1">
Enter stylesheet number (1-4):
<input type="text" name="inp" size="2" value="3" maxlength="1">
<input type="button" value="Change StyleSheet"
onclick="changeStyleSheet(document.form1.inp.value);">
</form>
<br><br>
<span id="spn">
Using the default stylesheet.
</span>
</body>
Step-2:
This is a sample text and here are some sample links:
http://fedora.redhat.com
http://java.sun.com
http://www.freebsd.org
Enter an integer (1-4) below, then click on the 'Change Style' button. Pressing the ENTER key will not work! To restore the original page, reload the page.
Using the default stylesheet.
Download the stylesheets mentioned above (right click and save target as):
|
©Ahsanul Haque Shovon
All rights reserved
|