javascript

jquery .html does not work with script

Hi all, my Code is like $("#leaderBoard").html("<script2 language=\"javascript2\"> document.write('<scr'+'ipt language=\"javascript21.1\">alert(1)</scri'+'pt>'); </script2>".replace(/script2/gi, "script")); ie8 not wirking at all. FF3 is exucuting but page gets blank and seems loading not ending. someone has a clue? i want to let pa...

Javascript: var functionName = function() {} vs function functionName() {}

I've recently started maintaining someone else's JavaScript code. I'm fixing bugs, adding features and also trying to tidy up the code and make it more consistent. The previous developer uses two ways of declaring functions and I can't work out if there is a reason behind it, or not. The two ways are: var functionOne = function() { ...

css page problem

Hello, The code I have pasted below is meant to display images on the middle 2 links without text and go back to text on the reset and fourth link. I have set display:none for the span tag only, but it does nothing. Is there anyway to do what I am after simply, without using a framework? edit: example <html> <head> <style...

No image, and no popup window

Hello, I hava an ajax application that will not display an image, or make a popup window from html stored in a file. This is the code I am usiong for the popup: echo '<script> function makewindows(){ child1 = window.open ("about:blank"); child1.document.write(' . json_encode($row2["ARTICLE_DESC"]) . '); child1.document.close(); } </s...

When does script added with RegisterStartupScript() execute?

When does script added to the page with Page.ClientScript.RegisterStartupScript() actually run? MSDN states "when the page finishes loading but before the page's OnLoad event is raised" but this isn't much detail. For example, can a script added with RegisterStartupScript assume the DOM tree has been built? Does the behaviour differ bet...

A question about "undefined" in Javascript

Today one of my friends said: if (typeof isoft == "undefined") var isoft = new Object(); is such kind of code is writted by a freshman and writes if(!isoft) var isoft = new Object(); I originally consider there must be some difference. But I can't find the difference. Is there any? Or are the two examples the same? Thanks. ...

Implementing Forum Live View with Ajax and JSP

I'm starting a personal project, so I have at the moment complete architectural/design control. I'm just planning out the structure at this point. My goal is some sort of web forum, chat thing. The difference is it should update live, new posts growing on client views soon after they've hit the server. I think to use ajax and jquery ...

How to write a prototype for Number.toFixed in JavaScript?

I need to round decimal numbers to six places using JavaScript, but I need to consider legacy browsers so I can't rely on Number.toFixed The big catch with toExponential, toFixed, and toPrecision is that they are fairly modern constructs not supported in Mozilla until Firefox version 1.5 (although IE supported the methods since vers...

Which CMS should I use to manage a small internet site without programming experiences?

I'm looking for a CMS system to manage a simple and small website. The website will be made with pure HTML and some JavaScript (perhaps prototype library). The reason while I'm looking for a CMS system is, because the customer will have the ability to change the content later by him self, and of course he didn't have any experiences with...

How to check if an embedded SVG document is loaded in an html page?

I need to edit (using javascript) an SVG document embedded in an html page. When the SVG is loaded, I can access the dom of the SVG and its elements. But I am not able to know if the SVG dom is ready or not, so I cant' perform default actions on the SVG when the html page is loaded. To access the SVG dom, I use this code: var svg = do...

How do I stop the browser from loading status?

The scenario: I dynamically create an iframe and a form inside it via JavaScript. The form is submitted via JavaScript and sends a POST request to a server. The request is received, but the browser stays on loading status (the progress bar at the bottom of the window keeps progressing and doesn't stop, only happens after form submissio...

Javascript Marquee to replace <marquee> tags

I'm hopeless at Javascript. This is what I have: <script type="text/javascript"> function beginrefresh(){ var marquee=document.getElementById("marquee_text");//set the id of the target object if(marquee.scrollLeft>=marquee.scrollWidth-parseInt(marquee.style.width))marquee.scrollLeft=0; marquee.scrollLeft+=1; setTimeout("beginrefresh()",...

JavaScript: Bitwise shift of long long number

I need to bitwise shift a value 64 times in JavaScript. But JavaScript starts rounding after 32. For example: for(var j = 0; j < 64; j++) { mask = mask << 1; console.log(mask); } This prints value from 0 to 1073741824 but then rounds of and starts printing 0. ...

Make available as download with JavaScript

I create a file in JavaScript. Now I want to be able to make it available to the user as a download is this possible? To be exact it is a KML File I create so its basic XML. ...

Is it worth it to code different functionality for users with javascript disabled?

I'm currently building a project and I would like to make use of some simple javascript - I know some people have it disabled to prevent XSS and other things. Should I... a) Use the simple javascript, those users with it disabled are missing out b) Don't use the simple javascript, users with it enabled have to click a little more c) C...

Trigger event after GDirections.loadFromWaypoints in Google Maps API

I'm attempting to add some text to the directions results the Google Maps API returns to the specified div (directionsPanel). This code below would work fine, except that the jQuery line fires before loadFromWaypoints has finished modifying the DOM. If I run that line by manually triggering it after the directions content has finished ...

Handling ASP postbacks from Javascript Widget

I am trying to make a small, data-driven widget that is populated with data from a database on the fly. I can load it initially just fine, but when the index of an ASP DropDownMenu is changed, the widget returns a 404. This could be a symptom of how I am using the Javascript, or how I am using the ASP. I honestly don't know for sure. ...

JS: var self = this?

Using instance methods as callbacks for event handlers changes the scope of this from "My instance" to "Whatever just called the callback". So my code looks like this function MyObject() { this.doSomething = function() { ... } var self = this $('#foobar').bind('click', function(){ self.doSomethng() // this.doSomethi...

Does anyone know of a good article for creating MVC based components/ extension methods?

I've a couple of extension methods I've been developing for a couple of projects, they currently rely heavily on some AJAX to make bits and pieces work. The problem is that they require copying and pasting JavaScript files to the project you want to use it in. As this JavaScript file only needs to be used once (all instances of the rend...

Avoiding a javascript race condition

Here's the scenario: My users are presented a grid, basically, a stripped down version of a spreadsheet. There are textboxes in each row in the grid. When they change a value in a textbox, I'm performing validation on their input, updating the collection that's driving the grid, and redrawing the subtotals on the page. This is all ha...