Getting The Href Bit Of An <a>
Aug 27, 2003
I am not really that good with javascript, but is there a way by javascript to get the href location of and <a>?
I am trying to write a javascript function that is able to read a html document, detects if there are links, and if there are, open them in a new windows.
View 4 Replies
ADVERTISEMENT
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
Jul 6, 2006
I've looked for this and I wouldn't know what the best practice would be
for solving the following problem.
We use a BASE tag in our HTML pages. Now we have some links that use the
<A HREF="#" onclick="...">Hello</Amethod to invoke a JavaScript.
However, because of the BASE tag, when clicking a link containing only a
# as 'href' it will load the root index.html file. What I want is it to
do nothing and execute the onclick handler.
Now I have two possible solutions:
- Replace the # with javascript:... and remove the onclick handler.
- Replace the A HREF by a SPAN having the same style as a link.
Both however, I've learn it isn't good practice to use javascript: in a
link. The SPAN as link would be a sort of Sim-HREF, which will probably
end up being trouble (span:hover anyone?). Anyone has a viable solution,
cause I must be missing something.
View 2 Replies
View Related
Jul 23, 2005
Can someone help me on this little problem. I am using the following
code in an xsl page.
The directed page is written in the javascript: submitOnClick();
<a href="#">
<xsl:attribute name="onClick">submitOnClick();</xsl:attribute>
Main Menu
</a>
The problem is that when href is given the # sign, the moment i click
on the link it first jumps to the top of the page, before moving to
the directed page.
This can be seen when the page is longer than the screen size.
Is there any other solution to rectify that problem ..........
View 1 Replies
View Related
Aug 20, 2009
I am looking for JS script to replace find all the href values on a page and replace those href values matching them with an array of values.my array, lets say is a = {'some.ex.com', 'abc.ex.com/tv', 'some. name. ex.com', 'bcd.ex.com/dir1/dir2/some.jsp' }; etc.i want to find all the URLs on a given page, check if each found url matches with any of the values in the array, if match found, just replace only "ex.com" with "example.com" for every match.
View 4 Replies
View Related
Nov 11, 2009
if f returns true then href gets 'executed', else not. Works in FF, GC. In IE 7 does not work. How to get this working in IE ?
<a onclick="return f();" href="../jsp/...">
function f()
{
[code]....
View 5 Replies
View Related
Jul 14, 2010
Please check out the code and tell me how can i use the variable as a href link.
var rand_link = new Array ();
rand_link[0]="asdhrfe22k";
rand_link[1]="iqh3wjhs8s";
[code].....
View 2 Replies
View Related
Jun 15, 2011
How to render a div next to href link, we are using JQuery. Below is code attached where when clicked the div gets rendered just below the tab of browsers, I want to render next to that of href link as there will be lot of href links in the webpage using the same div tag.
I cannot do it in css because it gets fixed at that position and I am using the same div for many of the href in a page but changing the contents of the div dynamically upon the user who clicks the link.
Image attached with code.
View 1 Replies
View Related
Oct 4, 2011
how can I stored the value within an a href tag for example my php page does this
Code:
echo "<li><a href="JavaScript:article('$id')">".$row['title']."</a> </li>";
which prints this code on my ajax page
Code:
<a href="JavaScript:article('40')">What is the difference between Archiving and Trashing an Article? </a>
I want to save the value within href so that I can use it later. Please note its ajax so location.href doesn't work.
View 15 Replies
View Related
Mar 4, 2004
I'm trying to setup a daily tip section and would like to use href tags within my javascript message. I suppose this is possible, anybody have any suggestions?
This works without <a href>:
Code:
var msg = new Array();
Stamp = new Date();
today = Stamp.getDate();
msg[1] = "Tip 1";
This doesn't:
Code:
var msg = new Array();
Stamp = new Date();
today = Stamp.getDate();
msg[1] = "Tip<a href="tip1.htm">View More info</a> ";
View 2 Replies
View Related
Feb 17, 2006
I have a couple of links of which I change location.href for tracking purposes.
The problem is that the links now no longer seem to open in a new window (which was accomplished using target="_blank")
Is this an error on my part or is this by design? Is there a workaround? I would prefer not to use window.open as that could get blocked by a popup blocker.
View 3 Replies
View Related
Feb 18, 2011
Is it possible to use an <a href> tag without adding any text link to it, usually we write <a href="....">Link to text</a>, but I want to omit the Link to text part, which however is completely removing my a tag. I need the <a> tag because am using the hover part for rollover effect
View 2 Replies
View Related
Jul 23, 2005
I'm passing the asp parameters using the url current page is files.asp and I'm using window.location.href=files.asp?action=deletefile to pass the action to the serverside
My code never got executed (like the page was cached) unless i put document.write("") before the window.location directive.
Here's the code:
function confirmDelete(x){
var potvrda=confirm("Kliknite OK za brisanje. Cancel za povratak.");
if (potvrda==true) {
trans="files.asp?action="+x;
document.write("")
window.location.href=trans;
}
else {}
}
View 9 Replies
View Related
Jul 23, 2005
I'm trying to use the onload event to load a series of urls.
What I find is that the onload function is only called one time
no matter how large the array. Here is the onload function.
var next_win = 0;
var win = window.open("", "", "");
function nextWin() {
if (next_win < urls.length) {
win.
win.location.href=urls[next_win++];
}}
Is this correct behavior?
View 10 Replies
View Related
Jul 23, 2005
<script language="javascript">
function ConfirmPage() {
window.location.href="http://ConfirmationPage.htm";
return false;
}
</script>
How can I use this script to display a page in my current directory? It woriks fine when using a domain such as yahoo.com or google.com.
View 3 Replies
View Related
Jul 23, 2005
I have a button that change a number of images src's when I click a
button. The src's are stored in an array and I just use
document[imgName1].src=pics[0] to change the src of the image.
However I want the button to change the link as well to the image that
is displayed but i cannot get it to work. How do I do this. Could
someone tell me or point me in the direction of some code that will do
this.
I would like to do it in a similar way to the pictures. i.e. have all
the links stored in an array and change them when the button is
pressed.
View 2 Replies
View Related
Oct 5, 2005
i have a really stupid problem with this line of code:
location.href = "showreport.php?id=" + sText;
sText is an id of a job that's running on the server.
Showreport.php retrieves the job and outputs the result in HTML. At the same
time job is removed from the server.
What happens is that some browsers (IE 6 mostly) like to GET the
showreport.php TWICE. Of course the second time there is no job any more and
the result returned is of zero length, which is very unpleasant ;-)
Headers sent by the browsers are (1st call):
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, */*
Accept-Language: sl
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322)
Host: veliswork
Connection: Keep-Alive
Cookie: PHPSESSID=tsghl22ijg4f6ba7a2mthggun6
Headers sent by the browsers are (2nd call):
Accept: */*
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR
1.1.4322)
Host: veliswork
Connection: Keep-Alive
Cookie: PHPSESSID=tsghl22ijg4f6ba7a2mthggun6
Note the Accept tag.
What's even more interesting, the accept tag of IE 6.0 that does not request
twice is:
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-shockwave-flash, application/vnd.ms-excel,
application/vnd.ms-powerpoint, application/msword, */*
Note the (still) absent application/pdf, which is the target content here.
Can somebody explain to me, why two calls and if that can be prevented. I
can reduce the problem by keeping the job for another minute or so, but
these jobs tend to be rather large (>10MB RAM usage) when large reports are
generated.
View 2 Replies
View Related
Nov 3, 2005
I'd like to call a JavaScript function which does something and loads at the
end a new page like <a href = "info.html">Next Page</a>
How can I do the above HTML command with a JavaScript?
View 5 Replies
View Related
Jan 26, 2006
I have a page that contains several HREFs. Each HREF that I'm interested in has a common parameter (parmX). Does anyone have a script example on how to find-and-replace parmX with parmY?
I'm assuming that I'd need to do this in the onload event - but I don't know much about Javascript.
View 8 Replies
View Related
May 21, 2006
I am trying to make a variable link on a page. The page has a text box
for a stock symbol. The code is: <input type=TEXTBOX Name="symtb"
value="" size="10>
The value of the text box {the stock symbol} will complete the url.
I found code for a variable link:
<script language="JavaScript">
<!--
function variable_in_link(varible_value)
{
new_win = window.open('http://finance.yahoo.com/q?s=" +
varible_value'')
}
// -->
</script>
The link I am trying to use is: <a
href="javascript:variable_in_link(symtb)">The text</a>
No matter what I do the variable_value comes back as undefined. There
is always a value in the text box.
View 6 Replies
View Related
Apr 23, 2007
I have a navigation page, very long list of urls and when you click a link it is opened in a new window.
THE PROBLEM:
When i scrolldown the navaigator and click on a link, it refreshes itself, even when i have target specified.
View 2 Replies
View Related
Jul 20, 2005
I am using some javascript code to change an image on an html page. I would
like the user to click on the image to bring them to another page. I need to
change an href to include an id value based on the image.
Here's the process:
1. select an image from a drop down list.
2. view the image on the same page.
3. click on the image to bring user to another page.
Here's my attempt at it:
function nextimg() {
txtString =
document.Topics.sel_val.options[document.Topics.sel_val.selectedIndex].value
document.image1.src = txtString.substring(txtString.lastIndexOf("&") + 1);
document.frmPic.href="details.asp?id=" & txtString;
}
I also think that txtString is not what I need. I believe it is a text
string (12345.jpg). So I will need to parse the string as well to get the
"12345".
View 2 Replies
View Related
Jul 20, 2005
I'm trying to get the href attribute from the base tag in the document
head. The following does not seem to work... any ideas what I'm doing
wrong?
if(!(document.getElementsByTagName) ||
!(basehrefs = document.getElementsByTagName('base')) ||
!(basehrefs.length) || !(basehrefs.length > 0) ||
!(basehrefs[0].getAttribute) ||
!(basehref = basehrefs[0].getAttribute('href')) )
basehref = ''
This is essentially a very cautious version of:
basehref = doument.getElementsByTagName('base')[0].getAttribute('href')
The big hairy if just provides checks to make sure everything can be
done and provide a contingency if it doesn't...
View 7 Replies
View Related
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
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