dhtml

Set content of HTML <span> with Javascript

我的梦境 提交于 2019-12-17 15:39:25
问题 In a webpage I am calling a WebService that gives me an integer value. I need to display this value in a block of text. I am currently using an HTML <span> . So far, I've found two methods of putting my value in a span. innerText() is an IE proprietary way of doing it and innerHTML() is a non-standards compliant way, although widely supported. What is the correct standards compliant way of setting the text between <span> and </span> from Javascript? 回答1: This is standards compliant and cross

Set content of HTML <span> with Javascript

烂漫一生 提交于 2019-12-17 15:39:06
问题 In a webpage I am calling a WebService that gives me an integer value. I need to display this value in a block of text. I am currently using an HTML <span> . So far, I've found two methods of putting my value in a span. innerText() is an IE proprietary way of doing it and innerHTML() is a non-standards compliant way, although widely supported. What is the correct standards compliant way of setting the text between <span> and </span> from Javascript? 回答1: This is standards compliant and cross

Boolean HTML Attributes

自作多情 提交于 2019-12-17 09:40:35
问题 There are some attributes in HTML which are "boolean" - browsers treat them as "true" if they are present, regardless of the value. An example of such an attribute is selected on the <option> tag. Another is checked on <input type="checkbox"> . If you have a call to setAttribute() for such an attribute, there seems to be no value you can set to have the browsers consistently behave as though the attribute is missing. For example option.setAttribute("selected", false) will still mark the

Modifying a query string without reloading the page

时光怂恿深爱的人放手 提交于 2019-12-17 08:12:04
问题 I am creating a photo gallery, and would like to be able to change the query string and title when the photos are browsed. The behavior I am looking for is often seen with some implementations of continuous/infinite page, where while you scroll down the query string keeps incrementing the page number (http://x.com?page=4) etc.. This should be simple in theory, but I would like something that is safe across major browsers. I found this great post, and was trying to follow the example with

Getting all selected checkboxes in an array

落花浮王杯 提交于 2019-12-17 02:55:10
问题 So I have these checkboxes: <input type="checkbox" name="type" value="4" /> <input type="checkbox" name="type" value="3" /> <input type="checkbox" name="type" value="1" /> <input type="checkbox" name="type" value="5" /> And so on. There are about 6 of them and are hand-coded (i.e not fetched from a db) so they are likely to remain the same for a while. My question is how I can get them all in an array (in javascript), so I can use them while making an AJAX $.post request using Jquery. Any

IE9 Scrolling bug (border line repeated on screen)

假装没事ソ 提交于 2019-12-14 04:10:04
问题 I'm doing a DHTML popup where there is a UL with left floated LI's, that show a list of embroidery designs. In ie9 (does not effect <=IE8) when you scroll down in the UL all of these lines start showing up that should not be there. It almost seems like the bottom border of the UL is tearing and staying on screen. To make things even more weird, when you scroll up, the lines disappear... Here is a screen shot of the problem: http://www.flyingtigerssurplus.com/bug-sample.jpg You can replicate

Can JavaScript tell the difference between leaving through the back button or a link?

允我心安 提交于 2019-12-14 04:09:07
问题 My application has pages with several tabs that simply switch the visible content. However, the page also has links that will add tabs to the page. In addition, the application remembers (with cookies) which tab you last viewed in case the page is refreshed (strict cache settings cause refreshes even when using the back and forward buttons). My problem is that the first time you visit this set of pages, it should show the first tab (Tab A). Then, you click a link, and it adds a tab, and it

Knowing how wide a text line will be in HTML for word wrap and other applications

落花浮王杯 提交于 2019-12-14 03:46:15
问题 Do you know a good cross-browser way of knowing how wide will be a text line so you can break it exactly to fit a fixed width? Suppose you want to break a long text like so it doesn't overflow a fixed width container, but you want the line to break the closest to the border possible, so guessing where to insert ­s isn't a clean solution. I want to investigate, I imagine this could be done having an invisible div then printing the line inside it and checking the div's width, or something like

Prototype plugin for dynamically expanding textarea

雨燕双飞 提交于 2019-12-13 12:22:36
问题 Does anyone know of a good plugin for prototype which allows textareas to automatically expand / contract based on how much text there is in them (e.g. a line is added the area gets bigger, a line is removed it gets smaller)? I need one thats free to use (e.g. some form of GPL type license). 回答1: This uses Prototype: <textarea id='t1' cols="40" rows="7" style='overflow:hidden;font-size:14px;font-family:"Times New Roman", Times, serif'></textarea> <script type="text/javascript"> function

If I use “getElementById” to alter a CSS style of a single object, how do I alter all elements that inherit the style?

爷,独闯天下 提交于 2019-12-13 03:47:40
问题 All the examples I've seen use "getElementById" to get the single element, and then change that style for that singular element. I'm in the situation where I need to modify all the matching elements on the page with a style. I need to change the font size, height, and width. How do I do this, and is jQuery required or optional? The reason I ask is because this site doesn't use jQuery and I'd rather not download the entire library just to accomplish this one thing. Update As an example,