javascript

JQuery Toggle Button Trigger

Hi all, i have this code: $('.access a').toggle(function() { $('link').attr('href', 'styles/accessstyles.css'); $('body').css('font-size', '16px'); }, function() { $('link').attr('href', 'styles/styles.css'); $('body').css('font-size', text_sizes[text_current_size] + 'px'); }); It works fine. But how would i programmat...

Make an h2 tag unremovable in a contenteditable section

is it possible to make a section within a contenteditable element permanent, so that a user cannot remove it? I have an h2 tag in a contentEditable div. I don't want the user to edit the h2 tag, so I set contentEditable=false, but the user can still select and remove it, which I want to disallow. So, for ex: <div contentEditable="tr...

Question about Content Delivery Networks CDN

I've built a javascript file that my clients will be installing on their website which will call my server. I'm wondering if it would be better to host the javascript file on a CDN, instead of on my server? The benefits would be better response time and a much higher chance that it will always be available. However, In the future, if ...

jquery script removal

I need to remove the following script from my page(ASP.NET 3.5), leaving all other scripts intact: <script type="text/javascript"> //<![CDATA[ alert('Save Sucessful.'); </script> Should be something like $('html').children('script').remove(':contains("alert")) but this exact syntax doesn't work. ...

Javascript data parsing in IE vs other browsers... It seems kinda screwed up. What's the deal?

Firstly, when I say other browsers I really only mean Firefox because that's all I tested in. Internet Explorer can parse a date followed by a single character as a proper date. Whereas Firefox behaves as I'd expect. For example... var dateString = new Date("1/1/2010f"); alert(dateString); In IE it will alert... Thu Dec 31 21:00...

C# run Javascript from button click

I have a button on my .aspx interstitial page. When I click it the onClick event fires off and it does a bunch of validations in the code. I have a javascript function that I need to call/run AFTER these validations are performed. This javascript function closes the interstitial page. How can I call the javascript function from my C#...

IE8 displays white page when adding Javascript

I recently created a website and added some jQuery into it. However doing this makes IE8 display a white page. Whenever I remove the Javascript IE8 renders the site fine. I have tested locally as well as on the internet, the problem still persists. This is my code to include my .js files: <script type="text/javascript" src="jQuery/jQue...

Javascript object list sorting by object property

I need to do this: (sorry not in javascript syntax-still learning object language :) ) object=car attibutes:top-speed, brand.... now I want to sort the list of those cars in order by top-speed, brand... How do I do this (please note the solution must be javascript only, no php or other stuff) ? ...

How do I do this SELECT/OPTION in HTML? (javascript)

Suppose I have this: <select id="myselect"> <option rel="a">1</option> <option rel="b">2</option> <select> How do I use JQuery so that onchange $("#myselect"), I alert the "rel" part of the option (not 1 or 2) ...

Name an id dynamically with javascript?

How can I dynamically name id's using javascript? Something like this: js: var idName = "fruit"; html: <img id="javascript:idName" src="banana.jpg"> ...

JavaScript to enable "submit" button (doesn't work)

I need the button "submit" to be disabled unless JavaScript is on. I tried: 1. <input onLoad="this.disabled=false" id="post-comment" type="submit" value="Post Your Comment" disabled="disabled"/> 2. <input onLoad="this.removeAttribute('disabled');" id="post-comment" type="submit" value="Post Your Comment" disabled="disabled"/> 3....

how to access dynamically created list in jquery?

hi, i have a unordered list of links, which are dynamically created by Ajax, and for each link i want to add click function to it, but it won't work, please help! here is my code: HTML: <div id="sidebar"> <li> <h2> list </h2> <ul id="list"></ul> </li> </div> JS: //to create links var str = ''; $.each(json.opts, fu...

Weird Javascript Regex Replace Backreference Behavior

why does the following js expression: "test1 foo bar test2".replace(/foo.bar/, "$'") result in the following string? "test1 test2 test2" is the $' in the replace string some sort of control code for including everything after the match??? this behavior was screwing with me most of the day. can anyone explain this? thanks a lot ...

sIFR3: controlling a and a:hover styles inside replaced through CSS rather than JS

For graceful degrading and minimal coding for the sIFR feature on my websites I would want to define styles in CSS as much as possible. Here's what I do: • Define a H3 tag to be replaced by sIFR3. • H3 comes in varying colors by CSS depending on it's container, say: body.blue-txt h3{ color: #009CDA; } body.white-txt h3{ color: #FFFFFF...

IE Not Picking up Blur Event (jQuery)

I did a quick search, but couldn't find a specific solution to this (I'm sure it HAS been answered) but, I need to figure this out... Anyone know why this won't work in IE? $(document).ready(function() { $(document).blur(function() { window.close(); }); }); And what to do instead? Thanks. ...

Lookup element by id within a DIV not injected in DOM

I have a DOM element in memory that is yet to be injected in the page DOM. I want to lookup an element by id inside this DOM element but document.getElementById wont work as the element is not yet in the page DOM. Any ideas on how to do this? P.S. I know one approach is to use element.querySelector() but since IE7 doesnt support it,...

jQuery ajaxForm "h is undefined" problem

I have a form that is brought up in a ajaxed modal which I am using for updating user details. When the modal loads I call a js function: teamCreate: function() { $j("#step1,form#createEditTeam").show(); $j("#step2").hide(); var options = { type: "get", dataType: 'json', beforeSubmit: before, // pre-submit callback succe...

How to start a marquee with JavaScript based on user input?

Hello everybody. I am trying to use JavaScript to start a marquee when a user puts their name into a textbox and then clicks a button. I've got an idea as to how to do it, but my script never fully works. Any help is appreciated! Here's what I have so far: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or...

how to remove dynamically loaded images in javascript

I'm loading in 3 images (named 1.jpg, 2.jpg, 3jpg) dynamically to 3 divs called "div1", "div2" and "div3". function loadImages() { for (var i = 1; i < 3; i++ ) { var img = document.createElement("img"); img.src = "vegetables/"+i+".jpg"; img.id = "a"+i+""; var divName = "div"+i+""; document.getElementById(divName).append...

Building Web Apps using MongoDB and ASP.NET MVC, Should I Use C# Drivers or Javascript Driver

I am developing asp.net mvc web app with MongoDB as the data storage. I want to know others opinion about what drivers to use. Should I use C# drivers which is supported by community? Or, should I go to use Javascript driver which is supported by Mongo. How stable is javascript driver? Thanks in advanced.. ...