Parse Href Attribute And Get All Of The /profiles/######## Part Of The Anchor Tag?

Aug 28, 2010

Right, so there are a bunch of links in this format: <a href="/profiles/########">username</a>

I'm using greasemonkey, and what I want to do is go through and get all of the /profiles/######## part of the anchor tag. I'm using Regex and I can't seem to get a match.This is what I have so far:

function ok() {
var names = document.getElementsByTagName('a');
var reg = new RegExp("WHAT GOES HERE?");[code]....

what is actually desired is I want there to be a way I can select these somehow as well..

View 1 Replies


ADVERTISEMENT

JQuery :: Matching All Anchor Tags With "http://" In The Href Attribute

Apr 19, 2010

I want to be able to match all <a> tags on a Web page that are external links, which would be signified by the href attribute starting with "http://", obviously. Then I want to add an attribute to the matching tags.

I ran across this script that is supposed to do that:

<script type="text/javascript">
$(document).ready(function(){
$('a[href^=http://]').attr('target','_blank');
});
</script>

But it doesn't work. I don't understand regex very well yet, so I'm not sure if that part of it is right, but the jQuery syntax looks correct to my inexperienced eyes.

I know jQuery is working on the site already, the script is below the call the the jQuery library, and yes, I do have the script in the Head tag of the page...

View 3 Replies View Related

Include A Css Class As Part Of Href Link?

May 13, 2009

I have no idea about javascript but wanted to use the Konami script on my site. This is the current code:

var kkeys = [], konami = "38,38";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ){

[Code]....

I just wondered how to get the javascript to include the class so that it acts in the same way it would if just clicking the link. I imagine this is upsettingly easy to do but I can't seem to find anything about it!?

View 1 Replies View Related

Change Anchor HREF URL?

Sep 9, 2010

I want to add a small but informative weather widget to one of my web sites. Having searched around, most are either too big or too simple.

I did find "one" that I liked but it links to a lame page. I would rather have no link rather than the one provided. The widget I like is a simple javascript "include file" similar to this one:

[Code]...

View 2 Replies View Related

JQuery :: Parse Links And Then Create A Unique Target Attribute?

Feb 22, 2010

I'm trying to parse my anchor tags, by getting all the href attribute available in the page, and then i will loop through this attribute values and then parse it. if each href value is equal to "mypage.com", the link will open to the same window, but if not it will open to a new window, more like the concept of determining internal and external links in a page.

View 6 Replies View Related

How To Intercept A Anchor Href Click

Feb 27, 2007

I have to intercept the click on anchor's because they do reload the page.

The anchors does use the href attribute to do the reload/jump.

How can I get the event of this? How can I prevent this?

View 3 Replies View Related

Hide Specific Href In Anchor?

Mar 13, 2010

I'm using a script that has the back-end functionality mashed up so I can't change it. An image with a link around it hides behind this:

$RateUserThumbnailLink$ And i'd like to disable the link somehow as the owner wants money for the edit which is ridiculous. Can anyone figure out a way of disabling the link it generates?

View 2 Replies View Related

JQuery :: Add Attribute To Anchor Tag Without Name / Id?

Aug 3, 2011

I have this anchor tag which is created through script [code]...

I'd like to add a title attribute to it. How would I go abouttargetingthe tag and then adding the title?

View 3 Replies View Related

JQuery :: Getting The Img Alt Attribute From Within An Anchor Tag?

May 27, 2010

I have tried for hours to work this out, but with no success.

<a href="IMG_0001.jpg" rel="album" title="IMG_0001"><img src="IMG_0001.jpg" alt="IMG_0001" /></a>
<script type="text/javascript">
jQuery.noConflict();

[code]....

All I want to be able to do is use the alt attribute in the image tag instead of the title attribute in the anchor tag.

View 2 Replies View Related

Validate Url Of Anchor Href Tag Entered Within A Textarea?

Jan 4, 2010

I have a page with textarea where user can enter html code for link exchange

I need to verify whether the code entered contains url in anchor's href tag having same url as that of reciprocal link. how can i do this?

View 4 Replies View Related

Using Href:javascript And Anchor Links On Same Page

Jul 8, 2003

I'm working on a project where we're using JavaScript to let users swap styles on a page. To accomplish this, I'm calling the script via href="javascript:swapcss()" on the switch styles button.

Some pages on the site have anchor links. On those pages, if someone swaps styles without hitting any of the anchor links, all is well. But if someone hits an anchor link and then hits the swap button (at this point the URL is pageid.html#anchor), the page just reloads to their anhor point without swapping styles.

Does anyone have a workaround handy? I've tried several alternatives I've found online (href="#" onClick="action"; href="javascript void(0)" ). Nothing works for this case yet. Code:

View 3 Replies View Related

Using HREF And ONCLICK In An Anchor Tag Doesnt Seem To Work

Aug 11, 2005

I'm trying to setup a page that uses JavaScript in a text link to submit a form:

<a href="do.htm" onclick="javascript:document.forms.Q01.submit();">

I also have added a fallback page in the href (do.htm) in case users have JavaScript disabled. But the JavaScript doesn't seem to be working. When I click the link it always goes to the fallback page, and doesn't submit the form.

I've tried swaping the order in the anchor tag (JS first, href second):

<a onclick="javascript:document.forms.Q01.submit();" href="do.htm">

and the same thing happens.

If I remove the href value:

<a href="#" onclick="javascript:document.forms.Q01.submit();">

the JS does execute properly.

How can I get the JS to execute by default for browsers that support it, and the href be the backup for browsers that dont support it?

View 1 Replies View Related

JQuery :: Toggleclass On A Link, With The Href Of The Current Anchor?

Mar 7, 2010

What am i doing wrong? I'm trying to toggleclass on a link, with the href of the current anchor

var anchor=window.location.hash;
$('#nav a[href='.anchor.']').toggleClass('active');

View 1 Replies View Related

JQuery :: Click Function Of Anchor Tag Not Working With Href Other Than #?

Jul 25, 2011

I started with the simplest step - the hide() function:

$(document).ready(function(){
$("a#p").click(function(event){
$("#HiddenDiv").hide();
})
});

It worked fine as long as the href attribute of the anchor tag was '#'. Then I tried using href other than '#' and ran into a problem. I just changed the href to:

<a id="p" href="test.php">Click me</a><br />
<div id="HiddenDiv">Testing mate</div>

test.php is the page in which both these sections (html and jquery) are present, so like a postback to the same page.

This method didn't work and on clicking the anchor tag, the div stayed visible.

I then tried theevent.preventDefault(); method and that worked.

So I experimented more. I tried using the hide function on a dynamic link, something like test.php?a=1.

I ran into a problem again. The div remained visible on clicking that link.

View 17 Replies View Related

Difference In Calling Javascript In Href And Onclick Of Anchor Tag.

Jan 18, 2006

I am looking for a generic javascript function to identify the form with in which a element exists, thus developer can avoid coding like document.forms[index].submit() - where they are sure, they want the form with in which this element exists is to be submitted. This way when forms are introduced at top level the code can remain unchanged, else every form introduce above in the DOM will result in increasing the index by one.

The code is given below. While doing so i am stuck with 2 problems
P1: In the code, you can see i am giving a explicit 'break' in the code. If i don't do so the code seems to be looping. Obviously i am missing some basic.

P2: I am able to pass 'this' for anchor element by name="xy"
<a href="#" name="xy"

in its onclick function by which, in the javascript function i move up the DOM.

While i am unable to do that on the anchor element given below since this function is now on the href attribute.

<a name="xy1" href="javascript:doFormSubmit(this);">Q test</a>

Hence the script fails. Code:

View 10 Replies View Related

Getting Href Attribute Of <base> Tag?

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

Change Href Attribute With Two Dropdowns

Nov 24, 2005

I am in a problems here trying to generate link by two dropdown boxes. So, I wanted it to be like when user selects some option from dropdown one the href attribute changes, index.php?staticvar=something&dynvar1=something, that is something I have already managed to do:

function change_href(id)
{
if (id != '')
{
var dynvar1 = document.getElementById("s"+id).value;
document.getElementById(id).href = "index.php?staticvar="+id+"&dynvar1="+dynvar1;
return;
}
else
{
return false;
}
}
This works perfectly for me, but now I need to modify the href with another variable, so it would be needed to be like:
index.php?staticvar=something&dynvar1=something&dynvar2=something2

The problem is that I don't know how to make it the way that user can change their selections, for example if user first selects (from dropdown) dynvar1 to be "test" and dynvar2 to be "test3", but then changes hes mind and decides to re-select dynvar2 to be "test4". It would be needed to be like only the dynvar2 part of the href changes with proper value (not changing the dynvar1 or staticvar).

I managed to make it changeable but it was like this:
index.php?staticvar=something&dynvar1=something&dynvar2=123&dynvar2=123

So, it didn't update the dynvar2 part, but instead just added another dynvar2 variable.

View 3 Replies View Related

Get String Variable In Href Attribute Of A Tag?

Jan 4, 2011

When I click the name, I should go the particular page about that person.

<script type="text/javascript">
if (window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.onreadystatechange=verify;
xmlDoc.load("a.xml");
[Code]....

View 1 Replies View Related

JQuery :: Child - Get The Href Attribute In A Variable?

Aug 3, 2010

How can I get the href attribute in a variable?

View 1 Replies View Related

JQuery :: Href Attribute IE Vs Standards Browsers

Aug 30, 2010

I'm having an odd issue that i can't recreate in jsbin.i have an anchor tag:

<a class="navigateToCategory" href="#523">Instruments</a>
and the code below:
$('.navigateToCategory').bind('click',function(e){
e.preventDefault();
alert($(this).attr('href'));
});

IE will give me [URL] while all other browsers give me "#523". I tried to recreate this using a small test case, but i can't do it. IE always returns the "#523" just like all the other browsers. here's a jsbin of it workinghttp://jsbin.com/unowe3/13 why .attr('href') would be different in IE vs Other browsers on my page but not jsbin? i'm using the same doctype and version of jquery, and identical code. i can't think of any code that i could have written that would affect how .attr('href') works. Edit: i did build a "hacky" solution for it by using $.browser.msie and an if statement, but it doesn't make any sense to me why it would be different in my situation vs any other.(not to mention, if it for some reason starts working properly, the "hacky" solution will cause it to not work)

View 3 Replies View Related

Running A Onclick Event On A Href Attribute?

Nov 24, 2010

Im a PHP developer and am quite new with javascript. I wanted some help on the hyperlink onclick event. Bascially I output a list of a href hyperlinks on a html page that goes all the way to the bottom of the screen. I wanted to add a onclick event to the a href tag that would pust the user right to the top of the page. I want to achieve this using javascript onclick event.

View 5 Replies View Related

JQuery :: Replacing Href Attribute With Title Attr?

May 9, 2011

I'm trying to replace the value of href attribute of an element with the title attribute of that same element. The code pasted below works to some extent, but the last line doesn't.

jQuery(document).ready(function(jQuery){
jQuery(".ngg-gallery-thumbnail a").each(function (arr){
if (jQuery(this).attr("alt").substr(0,5)=="Video"){
jQuery(this).attr("rel","wp-prettyPhoto");

[Code].....

View 2 Replies View Related

JQuery :: Selecting HRef Attribute - Vote And Post ID

Apr 19, 2010

I am trying to make a poll using jquery and php and am bit lost. I have a link
<a href="poll.php?vote_id=1&post_id=25">I agree</a>
Now how do I use jquery to select the vote_id and post_id. I need to store them in variables so that I can pass it on to a php file using get statement.

View 1 Replies View Related

JQuery :: Change The Href Attribute Of .load(ed) Content?

Jan 19, 2010

I'm pretty green to jQuery. I have a .load() calling in some content that has some links within it. After that content is loaded, am I able to change the attributes of those links? This is how I'm loading in the content:

$(".maincontent").load(pages[0] + '?' + tsTimeStamp + ' .maincontent');
Which contains:
<a class="table_button0" href="#"></a>
<a class="table_button1" href="#"></a>

[Code].....

View 2 Replies View Related

Sessions To Two Profiles?

Mar 15, 2010

I have two files which has two types of profiles (user and Admin), Now the problem is how do i create a session which if im a user takes me to the user page and when im admin takes me to admin page

View 1 Replies View Related

JQuery :: Refresh Href Attribute Of Link Via Ajax Every Five Seconds

Dec 14, 2010

I have links in my page in the form of this

<a href="example.php?key=someid" class="link">some link</a>

I want to refresh href attribute of link via ajax every five seconds, I am trying this,

[Code]...

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved