JQuery :: Changing An HREF Value?
Aug 28, 2010
What is a good way to switch a number at the end of a string?Im trying to change the value 0 to value 1 at the end of a URL when a button is clicked. (And vise-versa)So if I have this:<a class="important_ajax" href="projects/important_ajax/0"></a>Them the part here should be simple but im unsure of a good way to do this easily:
$(".important_ajax").click(function() {
$obj = $(this); // So I can use THIS object inside of other objects.
$url = $obj.attr('href'); // This is the URL: projects/important_ajax/0
[code]....
View 1 Replies
ADVERTISEMENT
Dec 7, 2011
I have external links on my website which are added by users of the system. I want to do the following:
1) Change the HREF value via jquery of any external hyperlink to be a page on my site that opens in a new window
2) This page will be a 'Please wait, we are redirecting you to your chosen website
' kind of page
3) This page then redirects the user to the URL they clicked after a couple of seconds
I thought of doing something like the following:
$('a[href^="http://"]').attr({target: "_blank", title: "Opens in a new window", href: "/redirect/"+$(this).href});
So the idea being that I open all external URLs in a new window but I load a page called /redirect (which is my own page) but I pass to it the URL I want to redirect too.
This is not working as each time I click my link my URL is:
/redirect/undefined
View 1 Replies
View Related
Sep 23, 2009
I am using an online e-commerce hosting solution and they wont let me modify certain pages because they have full control. Is there a way to do it through jQuery?
Here is the tag:
<a href="AccountSettings.asp?modwhat=change_a">Change e-mail address, or password</a>
I want to change the text "Change e-mail address, or password"
View 2 Replies
View Related
Nov 9, 2006
I want to change the href for all the <a> tags once the page has full loaded.
Is there any way to do it.
View 3 Replies
View Related
Apr 10, 2010
I need to run window.open() via href (not via onclick) as the CMS I'm working on only allows setting the href, not the whole <a> tag. I'm doing this: <a href="javascript: window.open('myUrl.php');">click this</a> and the window pops up just fine but the originating page changes to blank with '[object Window]' in it. How can I prevent the originating page from changing URL (by adding something to the javascript call)? Like "return void;" or something - but of course that didn't work...
View 2 Replies
View Related
Apr 28, 2011
I'm using a service to remotely create a pdf - it creates a pdf of the page you're on. Unfortunately that includes the link as well. I'd like to push the pdf generator to a slightly different url which would remove the offending link. The link I have is:
[Code]....
but it is not fooled! It seems I need to edit location.href but I don't know how to do it!!
View 2 Replies
View Related
Jul 12, 2010
I'm using the following code (simplified version) to call a Json file, parse it and on each iteration, create a div with an ID of "tab". I'm using this with jQuery UI .tab() to create a listing with entries which have three tabs. Anyhow, the principle seems to work except that when I examine what's happening behind the scenes using Firefox console, I see that each href in the html code produced is causing the Json function to re-fire using the href as it's url target.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
[Code].....
View 6 Replies
View Related
Feb 2, 2011
I am trying to dynamically clear the value of a form input field and then submit the form.When I used $('#my_field').val('') to clear the field, it was cleared on the screen but when the form was submitted the original value of the input field was posted.My browser is FireFox and I can see using FireBug that when the field is cleared, firebug is still showing the html code with the old value. E.G. <input type="text" value="old_value" />The same situation occurred if I used $('#my_field').attr('value', '') to clear the field.The same situation occurred if I actually changed the value of the field rather than just clearing it.To work around this problem I ended up using the $('#my_field').removeAttr('value') to clear the field before it was submitted.
View 1 Replies
View Related
Jan 12, 2011
I currently have a normal link like Code:<a href="http://sitepoint.com" class="link">sitepoint</a> and when a user clicks on it I want to be able to change the "link" class to a different class. However, I don't want to add anything to the actual link html. Is it possible to do this using javascript without modifying the original link code?
View 4 Replies
View Related
May 7, 2009
I am a complete novice when it come to Javascript. I copied the script for displaying random images at a specific interval (from javascriptkit.com). I would appreciate knowing whether the following is possible:
The pages are based on tables, so the parts that change are all cells.
1. Can I define text instead of an image in the array? i.e. can I have the image change to say an apple in one cell and the next cell have text explaining what an apple is?
2. Would it be possible to put a countdown timer for when the image/text is going to change?
View 7 Replies
View Related
Jul 6, 2011
Ive got a small image of a power button and when pressed the inner section on the button changes to yellow, but when its pressed down Im also trying to get part of my H1 (main header logo title) to change to yellow.
Ive created a span with an id surrounding the letters of the H1 that I want to change, the id being : "power";
The javascript that I have come up with so far and works is as follows:
<img id="poweron" src="http://www.sitepoint.com/forums/images/power.png" alt="Power on button" onmousedown="this.src='images/poweron.png';" onmouseup="this.src='images/power.png';"/>
I understand Im not really supposed to be using inline JS, and I know Ive got to create a function for the onmousedown event to trigger changing the H1 text, so am I under the right impression that the JS so far written is redundant and will have to be re-written so thats contained within a script placed just before the closing </body> and an external script for invoking the main function ?
View 2 Replies
View Related
Sep 23, 2009
I am using an online e-commerce hosting solution and they wont let me get certain stored data because they have full control.Anyhow the link on the page looks like this:[URL]How do I match and then get the full value of the url. The important value is 12.
View 2 Replies
View Related
May 6, 2011
I have a page with dozens of anchored links. When you click on the link, the appropriate div becomes visible. Each div contains an image. Because each DIV has a large image associated with it, it takes entirely too long for the page to load. I would like to set the IMG SRC inside of the div when they click. Each anchor href is the exact same name as the image to be loaded - so #dali would contain dali.jpg. How dow I pass the HREF minus the hash mark (#)? This is as far as I've gotten:
$("a").click(function() {
var whichDiv = $(this).attr("href");
$(whichDiv).attr("src", "images/art/" + whichDiv + ".jpg");
});
[Code]....
View 4 Replies
View Related
Jan 3, 2011
I wrote this code: $("#menu_nav_filter a").attr('href', $("#menu_nav_filter a").attr('href') + '#menu_nav_filter'); and I doesn't find all link, for example it finds: kamery.html?manufacturer=18 but should be: kamery.html?manufacturer=18&something=value&and=so_on
View 1 Replies
View Related
Mar 18, 2010
I have a link and i am putting the id in href.
Code:
<a href="12345" id="myLink">link</a>
In IE 8.0.6 and 6.5 (not my machine but on coworkers machine) when link gets clicked, i get full path including the ID like "http://www.domina.com/folder/12345" where as on my machine i get the ID only when i do
Code:
myval = $("#myLink").attr("href");
When i move the ID to rel attribute, the browsers behave as intended.
Code:
myval = $("#myLink").attr("rel");
same version of IE on my machine is behaving ok where as on coworkers machine it is not. Am i doing some thing wrong here?
View 6 Replies
View Related
Sep 26, 2011
I just need to replace a DIV with another DIV on mouse click.I'm assuming the best way to do this is with replaceWith().[code]
View 6 Replies
View Related
Nov 21, 2011
I have the following code and I need toreference the z-index value (something like if z-index:contains '2') but I have not been successfull. Anyone have a clue on how I can do this? <a href="javascript:RatingClicked('rate_value_vote_data_Herbieann','rate_display_vote_data_Herbie Mann', 5, 10)" style="width:50px;z-index:2">5</a>
View 5 Replies
View Related
Jul 22, 2009
I have a test blog I am working on at:
[URL]
I am trying to add some jquery image rollovers like the type featured on ThemeForest:
[URL]
I got the image rollovers to work, however I want to add links to them. Each time I add an href tag around the images, the script stops working.
View 2 Replies
View Related
Apr 7, 2011
I'm sure the answer to this question has to do with iterating over each element in the wrapped set, but I still don't understand why. I have a number of anchors in my page that have a class named Get.I want to append a querystring name value pair to the end of each href.
$(
'.Get').attr('href').append('&id=' + id); does not work. Can someone tell me why and what is the correct solution.
View 6 Replies
View Related
Mar 31, 2010
I have a simple image gallery consisting of an image with smaller thumbnails below that change on click which works fine.I now decided to change a link along with the gallery image source on click, but can't really get it working.Here is my code to swap the image to the clicked thumbnail image:
jQuery("ul.thumb li a").click(function() {
var mainImage = jQuery(this).attr("href");
jQuery("#main_view img").attr({ src: mainImage });
[code]....
View 2 Replies
View Related
Jul 13, 2010
I am trying to get a href attr from variable msg. The problem is that the msg consists of not only <a element but it contains also <p element and because of that attr doesn't give any value.
var msg="<p><a href='/users/'>Username</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
var href=$(msg).attr('href');
how I can get the value of href from the above example?
View 2 Replies
View Related
Jan 28, 2011
for example let's say we have:<a id="link" href="google.com">click</a>I want to be able to click the link, as if the click was made by the user ( left mouse button click ).I know I can do this way:document.location.href = $('#link').attr("href");but I believe it's not the same thing as if the user make that click.
View 1 Replies
View Related
May 25, 2010
I have tabs in my JSP, tabs are in divs as:
<div class="tabs">
<ul class="tabNavigation">
<li><a href="#DALmy_overview_tab">Overview</a></li>
<li><a href="#DALmy_sizing_tab">Sizing</a></li>
[Code].....
Somewhere in my JSPi have a link onclick of which i need to activate a tab, what should be my jquery?
View 1 Replies
View Related
Sep 28, 2011
sorry for the stupid question but how can i modify the href atribute of the link without having a id of the "<a>" just because it's the link of an image with an id?
<a href="anything.jpg"><img id="winkelchen" src="anythingelse.jpg" /></a>
View 2 Replies
View Related
Aug 22, 2010
I am doing a lightbox effect onclick a image.Its easy if I just use this code:
<a href="images/image-0.jpg" class="lightbox" title="Cape Breton Island"><img src="images/thumb-0.jpg" width="100" height="40" alt="" /></a>
<script>
$(document).ready(function(){
[Code].....
View 2 Replies
View Related
Feb 28, 2011
How do I search for all the <a> starting with with hrefhome?Example I could have 3 or 4 <a> that starting with the id of [code]
View 2 Replies
View Related