473,796 Members | 2,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ie gives a blank page with the below script, but fire fox works fine

40 New Member
Hi All
i am trying to change the font of my web page with user preference.i made use of cookie to get the user's preference, so that the font size selected will remain for the next session. i am changing the style sheet with the cookie set, The below shown is my code


Expand|Select|Wrap|Line Numbers
  1. function readCookie(name) {
  2.         alert("i am Reading the cookies");
  3.         var nameEQ = name + "=";
  4.         var ca = document.cookie.split(';');
  5.  
  6.         for(var i=0;i < ca.length;i++) {
  7.               var c = ca[i];
  8.              while (c.charAt(0)==' ')
  9.                 {
  10.                 c = c.substring(1,c.length);
  11.                 if (c.indexOf(nameEQ) == 0)
  12.                 return c.substring(nameEQ.length,c.length);
  13.                }
  14.  
  15. }
  16. return null;
  17. }
  18.  
  19.  
  20. function setFont(c_value)
  21. {
  22.  
  23. switch(c_value)
  24. {
  25. case 'big':
  26.  
  27. var navNam = navigator.appName;
  28. var navVer= parseFloat(navigator.appVersion);
  29.  
  30. if (navNam.indexOf('Microsoft') != -1 ) {
  31.         //IE 
  32.         document.write('<link rel="stylesheet" type="text/css" href="/imagesvariables_fonts_main_ie_big.css" />');
  33. }    else {
  34.         //Netscape
  35.         document.write('<link rel="stylesheet" type="text/css" href="/images/variables_fonts_main_net_big.css" />');
  36. }
  37.  
  38.  
  39.  
  40.  
  41.  
  42. break;
  43. case 'small':
  44. var navNam = navigator.appName;
  45. var navVer= parseFloat(navigator.appVersion);
  46.  
  47.  
  48. if (navNam.indexOf('Microsoft') != -1 ) {
  49.         //IE 
  50.         document.write('<link rel="stylesheet" type="text/css" href="/images/variables_fonts_main_ie.css" />');
  51. }    else {
  52.         //Netscape
  53.         document.write('<link rel="stylesheet" type="text/css" href="/images/variables_fonts_main_ie.css" />');
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60. break;
  61.  
  62.  
  63. }
  64.  
  65. }
  66.  
  67. function toggleFont()
  68. {
  69. var value;
  70. value=readCookie("size");
  71. var name;
  72. var c_value;
  73.  
  74.  
  75. switch(value)
  76. {
  77.  
  78. case 'big':
  79. alert("i am inside big");
  80. document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
  81. setFont("small");
  82. break;
  83.  
  84.  case 'small':
  85.  alert("i am inside small");
  86.   document.cookie ='size=big; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
  87.   setFont("big");
  88.   break;
  89.  
  90. default:
  91. alert("cookie not found!");
  92. document.cookie ='size=small; expires=Fri, 3 Aug 2020 20:47:11 UTC; path=/';
  93.  
  94.  
  95. }
  96.  
  97. }    
[HTML] //-->
</script>
<a class=pagenav href="#" onClick="javasc ript:toggleFont ();" >Text size</a></span>
[/HTML]


but the above code works in fire fox, but it is gives a blank page in ie,can any one help me with the issue?
Aug 3 '08
13 2259
Revathi Balakrishnan
40 New Member
Thanks for the reply acoder, i have used duplicate rel attribute. after seeing your advice, i have removed them after that the code works fine with ie, to have different style sheets for ie and Fire fox i have read the link given here.


Thanks a lot for help...

and i have one more requirement, Is it possible to swap image with the help of style sheets ? if i have style sheet a1, i should use image a1, if i have style sheet a2 i should use image a2. Is it possibel to do it?
Aug 5 '08 #11
acoder
16,027 Recognized Expert Moderator MVP
Yes, it should be possible. The best way would be to try it.
Aug 5 '08 #12
Revathi Balakrishnan
40 New Member
i have achived image swapping with the below code
Expand|Select|Wrap|Line Numbers
  1. <img  name="picture" src="icon1.gif" onClick="swapimage();"></a>
  2.  
  3. swapimage()
  4. {
  5. window.document.picture.src="icon2.gif";
  6.  
  7. }
  8.  
This is a very small tip, but hope it would be useful for new joinees of the javascript world
Aug 9 '08 #13
acoder
16,027 Recognized Expert Moderator MVP
I thought you were going to use stylesheets.

In your script, you should try to use IDs to refer to elements. See this simple example
Aug 9 '08 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

2
1906
by: Trent | last post by:
Hey All, I am new to javascript and currently coding a site with scripts that are beyond my level of understanding. The problematic page has thumbnail images that can be clicked on to zoom in. When clicked, the preloaded larger image displays in a div layer that gets turned on. The problem is that ie sometimes does not display the image - the placeholder just stays blank. The script works fine in firefox and netscape (haven't tried...
6
3019
by: Tony K | last post by:
I have the most peculiar problem with an ASP.NET page which we use for downloading a file. When the user clicks on a link, the link points to an ASPX page which downloads the file selected. The code works fine except after the user saves the file, the links on the left side of the frameset do not work. IE locks up.
1
1663
by: Tebogo Tefo via .NET 247 | last post by:
Hi I have a user control that contains three dropdownlists that I populate according to what was selected in the other dropdownlist (i.e. populate dropdownlist2 after selecting a value in dropdownlist1) The App works fine if I don't add the user control that I created and all events on the page work and thus the App is perfect. But as soon as I add my user control (Here used as the TopNav for my page) all
9
4923
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work fine from a link. The button does bring up the popup window, but when I press the links on the page, it doesn't return or close the window. ****************************************************************************
13
4011
by: kurtj | last post by:
Hello Gurus: I have a validation script (below) that is somehow messed up. If the Name field is blank, I get the alert message, then the browser window goes to a blank document with the word "false" on it. What the ?!?!?! To test, I commented out the 'return false;' code in the second IF block, so now if there is a value in Name then I get the alert message for Email and the page stays put.
6
1538
by: massic80 | last post by:
Hi, it's me again! I have a strange problem with a form I gotta (dynamically) insert in a site, and copied/pasted the code to a blank page, to make it easier to try it out. I was using the $ function of script.aculo.us, which is substituted by the equivalent document.getElementById in the code below (and the problem is still the same). The "mystery" is that this code WORKS both in FF 2 and IE 6, but IE gives an error at the moment when...
0
1610
by: manywolf | last post by:
I have an aspx page that fires the page load event twice for every load. I tried every fix that was suggested in all the posts on this and other forums. None changed the behavior. After one post that suggested they had an img tag with src="", I decided to look for instances of "src" and one by one start removing that code to see if it changed anything. Below is the one that, when I removed it, although it broke the flash menus and header, solved...
13
2975
by: raamay | last post by:
i have the following code which is generated from a .dwt template. My problem is that the page loads but only the header part displays and rest of the contents are not displayed. Everything works fine in my local testing server but when i upload it the hosting server the problem surfaces. I am not sure why? Please kindly go through my code below: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"...
0
9684
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10459
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10182
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10017
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9055
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5445
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5577
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4120
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3734
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.