javascript

jQuery / Javascript pass focus to next element while tabbing through page

I'm building a 'tag input' plugin with jQuery at the moment and I've hit a small stumbling block. I'm adding a button after a text input in a form, and using javascript to provide functionality for the button. When the button is clicked (or return is pressed in the input), the value of the input is added to a list of tags. The input is ...

How do you detect a website visitor's country (Specifically, US or not)?

I need to show different links for US and non-US visitors to my site. This is for convenience only, so I am not looking for a super-high degree of accuracy, and security or spoofing are not a concern. I know there are geotargeting services and lists, but this seems like overkill since I only need to determine (roughly) if the person is...

Adding more svg elements to my document at runtime

Hi, I have an html file, I'm adding am element to it dynamically, then a rectangle. Works well in the different browsers (ignoring IE). When I try to use the same method to dynamically create an element, it does not work in Chrome or Safari, only in Opera. Is my syntax wrong, or does webkit probably just not support adding elements a...

Can you set a JavaScript breakpoint in a UserControl?

Visual Studio 2008, ASP.NET. Can you set a JavaScript breakpoint in a UserControl ascx page? I can set it in an aspx page. ...

I don't want a specific path for my cookie using javascript

Hello, I am setting a cookie, but I don't want it to just work for one directory. How do I make it to where it's read throughout my whole site? I'm pretty new at JavaScript, thanks guys! <script> function setCookie(val) { var d = new Date(); d.setDate(d.getDate() + 300); document.cookie = "roster_count" + "=" + escape(val) + "...

RESTful cookie path fails in IE without trailing slash

I have been asked to build a tabbed section on pages that have RESTful URLs without a trailing slash (.NET MVC), for example http://myhost/books/the-amber-spyglass For the tabbed sections to be a bit more user friendly I want them to remember which tab was open on each page as the user moves around, so that if they return to a book the...

JQuery: How do I get a DID ID?

I have the following HTML: <div class="house">...</div> But in my code I dynamically insert in DIV ID's to make the code then look like this: <div class="house" id="id_1">...</div> Question: How can I get the DIV ID by only knowing the CLASS using JQuery? I've tried something like the following but it doesn't work. $('.house').ge...

Please help me refactor this jQuery code

I need to make this jquery run much faster, I did not create all of these functions, but need their methods, to do live translations of page content. So I would appreciate any suggestions to refactor for better performance, the code below. /* function 1 read json into array */ /* function 2 loop through array */ /* function 3 replace...

Problem displaying content added from parent window to child window in Firefox

Here is the code I am using to create and add content to a new window via JavaScript: var newWindow = window.open(); newWindow.document.title = "This is my new window"; newWindow.document.body.innerHTML = "<center>This is content added from the parent window</center>"; This works in every browser I have tested except ...

JavaScript regular expressions - match a series of hexadecimal numbers

Greetings JavaScript and regular expression gurus, I want to return all matches in an input string that are 6-digit hexadecimal numbers with any amount of white space in between. For example, "333333 e1e1e1 f4f435" should return an array: array[0] = 333333 array[1] = e1e1e1 array[2] = f4f435 Here is what I have, but it isn't qui...

make wmd-editor not post html?

I have code similar to the below <form action="/u" method="post"> <div class="reply"> <input type="hidden" name="type" value="2"/> <input type="hidden" name="id" value="1"/> <input type="hidden" name="parentId" value="0"/> <textarea name="text" style="width: 500px; height: 200px;"></textarea><div class="rhs"><button>Post Comment</button...

Reference calling DOM element in jQuery.ajax() with dataType 'script'

Let's say I have the following scenario: <form action="/something.php" method="GET">Click me</div> <script type="text/javascript"><!-- $('form').submit(function(e) { $.ajax({ url: this.action, method: this.method, dataType: 'script' }); return false; }); //--></script>...

Problem in executing the javascipt code in address bar

I really don't know whether i am supposed to ask such question here or not. But anyways, I am trying to run the following javascript code on address bar*: javascript:if ( document.getElementById('meebo') ) document.getElementById('meebo').style.display='none'; this meebo bar on any website is just an annoyance :x . Now the problem...

Understanding JQGrid column width behaviors

I have a tree grid with many columns, all with specified width. And boy, it looks terrible since headers are out of synch with columns below, even if I have short data in them. Specifically, if column Header title is shorter than this column width, Header shrinks down to the the size of text in header. How can I make header be exactly ...

jquery mouseout of nested div question

I'm trying to fire a function on the mouseout of a div. However when you mousover an element in the div it fires the mouseout. <div id="my_div"> <div class="another_div">X</div> </div> <script> $("#my_div").mouseout(function () { alert('weeeee, I am out!'); } </script> This makes sense but how can I test for the mouseout eve...

Javascript AJAX failing when put in to a function

I've written the following code to get JSON data with a POST request. $.post("http://example.com/songs/search_api/index.php", "data[Song][keyword]=Stereophonics", function(data){ /*$("#results").append(data);*/ alert("test"); var songdata = JSON.parse(data); //$("#results").empty(); ...

JQuery: How to get name of a select when value is known?

Hi, I need to get the name of a select (#Dropdown) when its value is known but can't seem to get the syntax right. Here's an example: $(document).ready(function() { var countrycode = '55'; var name = $("#Dropdown[value=countrycode]").text(); // fails here if(name == 'Germany') {..... etc I can get it to work as follows i...

JQuery/Javascript - how to minimize duplicated code?

If I wanted to use the following code on multiple DIV#ID, how do I do so without duplicating code var scrollElem = $('#div1'); scrollElem.scroll(function() { /* find the closest (hlisting) home listing to the middle of the scrollwindow */ var scrollElemPos = scrollElem.offset(); var newCenter = $(document.elementFromPoint( ...

Dropdwnlistbox using Javascript

I have dropdownlist box and two radiobuttons If i check first radiobutton, 1,2,3 vil be added to dropdownlistbox. If i select second radiobutton, 4, 5,6 will be added t dropdownlistbox. All these are created using java script.Here my problem is, Ididt select the drpdownlist values when i select any radiobutton Please help me ...

onclick open window and specific size

i have a link like this: <a href="/index2.php?option=com_jumi&amp;fileid=3&amp;Itemid=11" onclick="window.open(this.href,'targetWindow','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,') i want the window that is opening to be a specific size. how do i specify the height and width? ...