Jump to content
Sign in to follow this  
ahill

css does not work with javascript in IE

Recommended Posts

I am currently using the CSS width: 100% property in my drop down list in my classic asp page. My JavaScript call this asp page and does the work from there. My box displays fine in Google chrome amd wraps the text to the box but the css is ignored in Internet Explorer and runs off the page. Any ideas how to work around this?

Share this post


Link to post
Share on other sites

can we see the CSS and HTML?

Share this post


Link to post
Share on other sites

Hey guys I have a search box that works but I have 2 issues.1. I cant get the text to wrap.2. I cant put space between each of my results like a <br>Everything else works except for these two issuesHere are the links to my codeIndex------------------------------http://www.codelocker.net/30493/searchbox/livesearch-------------------------------http://www.codelocker.net/30494/searchbox/

Share this post


Link to post
Share on other sites

One problem is that your ASP page is returning a complete HTML document. You don't put one HTML document inside another one, it should only return a snippet of HTML that you'll add to the parent page.

Share this post


Link to post
Share on other sites

.wrapword{white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */white-space: -pre-wrap; /* Opera 4-6 */white-space: -o-pre-wrap; /* Opera 7 */white-space: pre-wrap; /* css-3 */word-wrap: break-word; /* Internet Explorer 5.5+ */white-space: -webkit-pre-wrap; /* Newer versions of Chrome/Safari*/word-break: break-all;white-space: normal;width: 160%;;}

First, it doesn't really do anything to duplicate all of those properties, it's going to use the last value. It's going to use "normal" for white-space and "break-all" for word-break. Second, giving an element a width greater than 100% is going to cause part of that element to be hidden, part of the text is also going to be hidden. Third, text inside select options does not wrap at all, the select box will match the size of the longest option unless you restrict it to be smaller, and if so the text will just get cut off. If you want text to wrap then you need to use a fake select box which is made from other elements like divs. jQuery has several plugins to replace standard select elements with more flexible things, for example.

Share this post


Link to post
Share on other sites

Any chance you could show an example of the wrapping. I had to do the 160% because I had to put the box -px to make it extend to the left of the box so I could only use 160% to make it go to the right. it still cuts it off if I use lets say 60%.

Share this post


Link to post
Share on other sites

It's a third-party library. There are several other plugins like that one. That one in particular doesn't say it requires any certain version of jQuery, so I imagine the most recent version would work.

Share this post


Link to post
Share on other sites

It's a third-party library. There are several other plugins like that one. That one in particular doesn't say it requires any certain version of jQuery, so I imagine the most recent version would work.

So I don't need any software installed on my server to use it? do I just put a link into the code to a library?

Share this post


Link to post
Share on other sites

You don't need to install software. It's a Javascript file that you link like any other Javascript file. There are places that host it where you can link to it on their server, or you can upload a copy of it to your server and link to it there. If you want to use it you should probably learn about it.http://learn.jquery.com/about-jquery/

Share this post


Link to post
Share on other sites

Yeah, the plugin would replace the select element with a widget that works similarly but has more features available to it.

Share this post


Link to post
Share on other sites

You can paste code directly in your post, there's a code box that will highlight it.What exactly happens when you run that? Is the code you showed there the response to an ajax request? If so, Javascript code doesn't automatically execute if you use something like innerHTML to add it to the page.

Share this post


Link to post
Share on other sites

yes it displays as a dropdown of results in an Ajax search box. looks the same as when I started but is not text wrapping yet. I believe I have the jquery there now but need to figure what css property is used to wrap the text in jquery

Share this post


Link to post
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
Sign in to follow this  

×