Jump to content

How to get css and javascript to work with IE*


rogerio
 Share

Recommended Posts

This code works great with Firefox, but not at all with IE8. It is designed to click on a link and open a .css popup. Clicking on the text in the popup will close it. What's the problem IE8? thanks...

<?xml  version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:w="urn:schemas-microsoft-com:office:word"xmlns="http://www.w3.org/TR/REC-html40"><head><style type="text/css">.popup{   position:absolute;left:0px;top:13px;width:300px;height:400px;border-style:solid;border-width:4px;border-color:blue;background-color:#000000;padding: 5px;font-family: Tahoma;/*   font-weight: bold; */font-size: 10pt;z-index:2;visibility:hidden;overflow:scroll;}/* ie bug needed to make span show*/.popup a:hover span{top:0px;}body{color:white;background-color:#000040;font-family: Tahoma;font-size: 10pt;}.link{color:blue;}.test{color:red;}.nottest{color:white;}</style><script type="text/javascript">function ShowPop(id){   document.getElementById(id).style.visibility = "visible";}function HidePop(id){   document.getElementById(id).style.visibility = "hidden";}</script></head><body><span style="position:relative;" class="test"><span id="popup3" class="popup"><a onClick="HidePop('popup3');" style="cursor:pointer;"><i>-Click in window to close-</i><p></p>this is a test</a></span>,<a onClick="ShowPop('popup3');" style="cursor:pointer;"> <u>testing</u></a></span></span></body></html>

Edited by rogerio
Link to comment
Share on other sites

are you checking for any errors in the console? you might have to spell the event handler all in lowercase, i.e. onclick

Edited by thescientist
Link to comment
Share on other sites

I don't know, I am running Win7 x64 and after clearing history it still fails. thanks for the help... EDIT: I just made a change from <a... to <a href="".... and now it opens Explorer. This thing is strange.EDIT2: Changed <a href="" to href="javascript:void(0);" and got rid of the Explorer problem.

Edited by rogerio
Link to comment
Share on other sites

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">should be<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">IE needs this to be correct for it to become as good as other better browsers.I should also get rid of MS office reference and use

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Title of Document</title>

instead of

<?xml  version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:w="urn:schemas-microsoft-com:office:word"xmlns="http://www.w3.org/TR/REC-html40"><head>

Link to comment
Share on other sites

dsonesuk, tried your suggestions, but no-go. I have a "hover" box working with no header at all - I did try that. May well be that there is something wrong with the IE8 other than the normal bugs; it is impossible to remove it completely and install a new copy without formating the HD, and as a vote of 1, I don't want to do that.

Link to comment
Share on other sites

You have several options, but first! you do realise IE9, comes with IE7 and 8, compatibility mode, press F12 click 'Browser Mode IE9' and select the version you require to test with. Windows XP mode, use this and as IE9 only works in W7, you can install IE8 the highest version it will take, I can't remember if IE7 is default version, if it is, select update, and update it to IE8. IETester (google) download this and you can use IE5.5 to present IE browser versions. The only problem that i can think of is that windows7 64 might not to apply to accept installation and running of these options.

Link to comment
Share on other sites

uh, yea. A couple of things on this. I had IE9 installed and had problems with the colors. I can't install XP Mode because the OS is OEM, and according to IETester, XP Mode is required. The default browser on 7 is IE8; IE8 has a IE7 compatibility mode. I don't know, this one is a bear; it appears that MS may have added some security. I haven't given up - just plain stubborn. What I need is a .CSS box that can be activated by clicking on a HTML link.

Link to comment
Share on other sites

ok, worked on tags and problem remains. In IETester: IE8 & IE6 work, but IE7 will not open the page. I disabled "Compatibility mode in IE8 and the browser still does not work. I don't know why IE7 does not work, but if I am correct, there is a setting that I have wrong in IE8???????

Link to comment
Share on other sites

New code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>Title of Document</title><style type="text/css">.popup{   position:absolute;left:0px;top:13px;width:300px;height:400px;border-style:solid;border-width:4px;border-color:blue;background-color:#000000;padding: 5px;font-family: Tahoma;/*   font-weight: bold; */font-size: 10pt;z-index:2;visibility:hidden;overflow:scroll;}/* ie bug needed to make span show*/.popup a:hover span{top:0px;}body{color:white;background-color:#000040;font-family: Tahoma;font-size: 10pt;}.link{color:blue;}.test{color:red;}.nottest{color:white;}</style><script type="text/javascript">function ShowPop(id){   document.getElementById(id).style.visibility = "visible";}function HidePop(id){   document.getElementById(id).style.visibility = "hidden";}</script></head><body><span style="position:relative;" class="test"><span id="popup3" class="popup"><a onClick="HidePop('popup3');" style="cursor:pointer;"><i>-Click in window to close-</i>this is a test</a></span><a onClick="ShowPop('popup3');" style="cursor:pointer;"><u>testing</u></a></span></body></html>

Link to comment
Share on other sites

This is going to sound crazy and it may very well be that I am.1. Found a code on the web that worked in FF and IE8 while still on the web.2. Opened the "View Source" in FF and copied it into notepad and ran it with FF with no problem.3. Tried IE8 and it would not work.4. Went to same site with IE8 and saved the page directly and it worked with both browsers.5. I opened the code in "4." above in notepad and compared it to the code in "2." above and they were identical.6. Copied the code in "2." above into the notepad window of "4." above and it worked in IE8.7. I tried taking FF and saving the page from the web directly and it worked for IE8.8. I last took the code listed here and pasted into the notepad of "4." above, save it and it worked in IE8. The best I can figure out is that something is being saved with the webpage that I can't see and without that info I am getting no where. My intent is to use the notepad window that works and paste in the code and save it that way. If anyone has any suggestions - YOU HAVE GOT MY EAR.... thanks.... EDIT: I tried this with another editor besides notepad and it did not work - only works with notepad.

Edited by rogerio
Link to comment
Share on other sites

Didn't work. There is something hidden going on and I am going to look some more. I don't have a real html editor and I was using SciTe (which is designed for .exe) may be doing something. I haven't worked with webpages for several years now and I seem to be having problems with IE loading external files on my PC (img, js, etc); does IE need to be on the internet to work properly?

Link to comment
Share on other sites

Finally got part of the answer. I kept fighting this thing and I should have used my head. I am running 3 OS on this machine and one is a backup Win 7. I load the page into the back up and things worked great. It looks like there is a security setting somewhere that is blocking things; in particular: running the javascript. I even loaded IIS and that would not work. If anyone has any ideas, I would appreciate the help... thanks,

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...