javascript

[Javascript] Getting the URI used to load a div on a page?

I have a div on a PHP-generated page loaded through jQuery's .load() function. This div contains a long list which has been paginated (links for page 1, 2, 3... 25, etc.). I'd like to write a function which will preserve the variables in 'search' portion of the URI (which is to say at the end of the URI: ?foo=1&bar=pancakes) and stick ...

Selecting a node in Raphael javascript

Hi, the following code mostly works (thanks to a good answer a couple of days ago!) all except for the last little bit: things.square[1].node.setAttribute("id","clicker"); $("#clicker").click(function(){ $("#canvas_things1").fadeOut(); $("#canvas_things2").fadeIn(); }); I think the problem is this line: things.square[1].node....

Javascript this in jQuery

Hello, I saw some old code that had: <input type="submit" name="submit" onsubmit="somefunction(this)" /> I was jQuery'ing the script, how do I get the pure javascript (this) object in jQuery? $("input[name=submit]").click(function() { somefunction(// ?? is it $(this) ); }); Thanks! ...

Force .change() function to run - jQuery

I have a .change() function set for a dropdown menu with an ID of #country. When the page loads, I'm trying to set the dropdown menu to "United States" and run the .change() function: $('#country').change(function () { resetDisclosure(); var countryCode = $(this).val(); var countryName = $('#country option:selected').text()...

Keeping Pop-ups in viewport

Hello, I am using a Superfish plugin to display menu pop-ups but the problem is when a menu item is big it gets overflow from viewport. How can I adjust the position of pop-up menu to always keep it in the viewport. ...

Is writing a cookie very slow in JS?

I need to make my website faster on the client side. I wonder if my excessive Javascript cookie manipulation could slow down the browser. It uses the harddrive, which is the slowest component of a computer. On a severely fragmented harddrive, could cookie manipulation freeze the browser? Is JS doing any optimizations for cookie writing...

Link isnt working when positioned with a background image?

I've got this link <a href="/Admin/Product/Brands" class="newButton"></a> Without the class attribute and a little bit of text, the link works fine, but when I add the class to apply the background image and position the button, the link stops working. It gives no errors in the firefox console either. Any ideas? Heres my css rule for ...

HTML encoding &deg; degree symbol extra space

<div id="a">°F</div> $.get("http://blah.com/go",{'TU':$('#a').text()}); IIS server logs show the following params: 99.5% of the time: TU=%C2%B0F 0.5% of the time: TU=%C2%B0+F server subsequently crashes because it doesn't know what '° F' is. Admittedly one of the flaws is that we are scraping text out of the DOM & sending it to our...

Resize echo text

I have a page that displays text the user typed in a form before that. If the user types a lot in the form and submits, the page that displays the text has a horizontal scroll bar. How could I make the text automatically do a line break after the text fills the screen? It needs to be 8.5 x 11 so it will print. What should I do to the tex...

Where to place my JS code and where/how to load multiple jQuery plugins?

I have a couple of questions that are somewhat related so I'm posting them all on a single question on SO... Question 1: I'm currently doing this Facebook application where I'm using jQuery UI Tabs, there's only 4 where 2 of them are loaded through Ajax. The main page is index.html, this is where the tabs code is placed and for the 2 t...

JQuery: .getScript() is not working when loaded from a .load()

You can see the way its suppose to work by visiting: link text That is loading everything using standard loading. You can attempt to get it to load dynamically here: link text and then simple just click the "Parts" link... As you can see no alert every comes to me. I have a feeling it has to do with the ability of detecting when to fi...

Why is it acceptable to expect that Flash will be available/enabled, but not JavaScript?

It doesn't take long when surfing the web to observe the general consensus that Flash is an expected standard, that it's okay to say "If you don't have Flash, my website won't work." Yet in the same regard, JavaScript is expected to degrade peacefully if the user does not have it enabled. I personally favor the "HTML5" approach, in oppo...

Javascript bookmarklet to click a button found by unique name

I need a javascript bookmarklet which can click on a button. The thing is, there are 100+ buttons on the page all with the same value. The name is unique but quite long. The full name of the element is something like : actions[http://apps.facebook.com/frontierville/giftaccept.php?next=giftaccept.php&amp;amp;senderId=1%3A1325206719&amp...

Dashcode - How do I get the name of a button from an event?

In Dashcode you can set up a handler for a behavior in the inspector. Here's a sample handler for a button click on a button I've named "mybutton1" in the Inspector: function myGetButtonName(event) { var e = event.target; alert(e.id); } The problem is, when the button is clicked and the alert comes up it says the ID of the bu...

How to Get Element By Class in JavaScript?

I want to replace the contents within a html element so I'm using the following function for that: function ReplaceContentInContainer(id,content) { var container = document.getElementById(id); container.innerHTML = content; } ReplaceContentInContainer('box','This is the replacement text'); <div id='box'></div> The abaove works...

JavaScript: How to pass an anonymous function as a function parameter?

I would like to write a function that accepts an anonymous function as a parameter. For example: run('param1', function(){ alert('execute this'); }); function run(param1, callback) { //now execute the callback parameter as a function } How can I achieve something like this? ...

Serializing a javascript array with Jquery

I have the following code: <script type="text/javascript"> var checksSinceLastPostBack = new Array(); function clientSelectedIndexChanged(sender, eventArgs) { var ajaxManager = $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>"); var serializedCheckData = checksSinceLastPostBack.serializeArray(); if (ajaxManager != nu...

How can I test if a user viewing my website can not see some content, and how can I make sure my test works?

I'm using code similar to below: var image = new Image(); image.src = "http://youtube.com/favicon.ico"; image.onload = function(){ // The user can access youtube }; image.onerror = function(){ // The user can't access youtube }; Which I found here: http://stackoverflow.com/questions/286021/detecting-if-youtube-is-blocked-by-company-is...

Post to multiple user profiles from a Facebook app

I am developing a web application that I want to integrate with both Twitter and Facebook. At a certain time, messages will automatically be published on every user's feed, for both their Twitter and Facebook accounts. I am currently working on the Facebook component. I know that in order to post to a user's feed on Facebook they must ...

how can I use php to create Latlng with address for google map V3

Hi there, I done a lot research but can't find the way to create latlng in the google map as below, how can I use address for the latlng number? the script is function initialize() { var latlng = new google.maps.LatLng(-41.251290,174.803638); var opt = { center:latlng, zoom:10, mapTypeId: google.map...