w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Custom Javascript href selector
I think querySelectorAll should do the trick if you don't need to support IE < 8 (http://caniuse.com/queryselector)

Categories : Javascript

Replace all links(href) in a web page using jquery
Try this: $('a[href*="sites.com"]').each( function(){ // Do a substring here to keep the beginning of the path (domain) $(this).attr("href", "http://any.sites.com/"); })

Categories : Javascript

Get value of HREF for links within a certain Class in Javascript
Use Element.attributes instead of Element.innerHTML. With your HTML you also need to use an inner loop to get <a> children of .r elements: var domains = document.getElementsByClassName('r'); for(var i = 0; i < domains.length; i++){ var anchors = domains.getElementsByTagName('a'); for (var j = 0; j < anchors.length; j++) { alert(anchors[j].attributes.href); } } or you could switch to Element.querySelectorAll() for a nicer querying API: var anchors = document.querySelectorAll('.r > a'); for (var i = 0; i < anchors.length; i++) { alert(anchors[i].attributes.href); } Note that I reused the domains variable since there's no reason to keep re-querying the DOM at every loop iteration.

Categories : Javascript

href links to Bootstrap nav tabs not activating on same page
Here is a generalized example which will work with nav-pills and nav-tabs Allows any link to also control the tabs for that "on-page" navigation. HTML <a href="#aaa" class="control-tabs">Another Link a</a> <a href="#bbb" class="control-tabs">Another Link b</a> <ul class="nav nav-tabs"> <li><a href="#aaa" data-toggle="tab">AAA</a></li> <li><a href="#bbb" data-toggle="tab">BBB</a></li> <li><a href="#ccc" data-toggle="tab">CCC</a></li> </ul> <div class="tab-content" id="tabs"> <div class="tab-pane" id="aaa">...Content...</div> <div class="tab-pane" id="bbb">...Content...</div> <div class="tab-pane" id="ccc">...Content...<

Categories : Javascript

jQuery find phone numbers on page and wrap in links
You can replace all instances of your phone number with regex js var text = $("body:first").html(); text = text.replace(/(phone-number)/g, "<a href="tel:$1">$1</a>"); $("body:first").html(text); html <div id="departments"> <ul> <li> Department 1 - phone-number</li> <li> Department 2 - phone-number</li> <li> Department 3 - phone-number</li> </ul> </div>

Categories : Jquery

A Comprehensive Regular Expression to find URL, links,page links, website links from HTML Page or String
Have a look here http://regexlib.com/Search.aspx?k=URL&AspxAutoDetectCookieSupport=1 You can find a lot of examples and patterns there and there are a lot of general Regex tutorials and articles. After a quick browse I found this : ([dw-.]+?.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(|W(?<!&|=)(?!.s|.{3}).*?))(s|$) Should do the trick, but I'm sure there are more elegant examples on that list.

Categories : C#

Cannot change padding on visited links?
Unfortunately, due to security concerns, the list of styles you are allowed to apply to :visited elements is limited. In the past, hackers have been able to sniff history from users by checking for differences in styles of normal links, and ones the user had previously visited. More on the security concerns here, and what styles are allowed: https://blog.mozilla.org/security/2010/03/31/plugging-the-css-history-leak/ As for allowed styles and modifications to :visited elements, here is a what MDN has documented on the subject: You will still be able to visually style visited links, but there are now limits on what styles you can use. Only the following properties can be applied to visited links: color background-color border-color (and its sub-properties) outline-color fill and st

Categories : HTML

Is there no known way to get visited links with jQuery in modern browsers?
No. (If there is, it's a security bug and probably won't exist for long.) If all you care about is styling, you should be able to achieve it through CSS, but through what is displayed on screen should be the only way to observe it being visited.

Categories : Javascript

CSS background color is not applied consistently to visited links. CSS added by GM_addStyle
From Privacy and the :visited selector at MDN: Only the following properties can be applied to visited links: color background-color border-color (and its sub-properties) outline-color The color parts of the fill and stroke properties In addition, even for the properties you can set for visited links, you won't be able to change the transparency between unvisited and visited links, as you otherwise would be able to using rgba() or hsla() color values or the transparent keyword. Apparently, this means, in Firefox, that in order for you to change the background color, the link must first have a background (which you can't add using the :visited selector). So set the background before trying to style visited links' background color. This works for me: // ==Use

Categories : CSS

Replace Page Links on Popup Page With Javascript to Open in Main (Parent) Window
You cant replace attribute target, from attribute href. use el.target and just set the value var aEls = document.getElementsByTagName('a'); for (var i = 0, aEl; aEl = aEls[i]; i++) { aEl.target="_parent"; }

Categories : Javascript

Javascript window.location.href - Refreshes page instead of redirecting
From the Mozilla Developer Network documentation, href is the entire URL of the page. The only relative property in that list is path, which is relative to the host or the domain of the page. You may also want to look at using the reload or replace method. See How can I make a redirect page in jQuery/JavaScript?

Categories : Javascript

Element's href attribute is removed with javascript but still it is present in page source
The page source is what was downloaded originally. The browser parses the HTML and builds the DOM (Document Object Model), which is an in-memory data structure containing the browser's internal representation of your rendered page. Javascript updates the DOM, not the source. If you want to see the updated DOM you must use a tool like Firebug.

Categories : Javascript

JavaScript all links on a page with regex
Newer browsers: var links = document.querySelectorAll('a[href^="/item/"]'); Older browsers: var links = []; var elements = document.getElementsByTagName('a'); for (var i = 0; i < elements.length; i++) { var a = elements[i]; if (a.getAttribute('href').indexOf('/item/') === 0) { links.push(a); } }

Categories : Javascript

javascript could not work when refresh page
from the jQuery Mobile docs: Important: Use $(document).bind('pageinit'), not $(document).ready() The first thing you learn in jQuery is to call code inside the $(document).ready() function so everything will execute as soon as the DOM is loaded. However, in jQuery Mobile, Ajax is used to load the contents of each page into the DOM as you navigate, and the DOM ready handler only executes for the first page. To execute code whenever a new page is loaded and created, you can bind to the pageinit event. This event is explained in detail at the bottom of this page. so change your $(document).ready() to $(document).bind('pageinit') and it should work.

Categories : Ajax

Refresh page after action in javascript
Put your page refresh code in complete call back Example: $.ajax({ type: "GET", url: "ajax_image.php?t=ajax&img=" + $("#image_name").val() + "&w=" + thumb_width + "&h=" + thumb_height + "&x1=" + x_axis + "&y1=" + y_axis, cache: false, success: function (rsponse) { $("#cropimage").hide(); $("#thumbs").html(""); $("#thumbs").html("<img src='images/" + response + "' />"); }, complete: function() { location.reload(true); } }); Hope this will help !!

Categories : Javascript

Javascript keep div toggled on page refresh
Use a cookie plugin like this one, then function showonlyone(thechosenone) { $('.newboxes').not('#' + thechosenone).hide(600); $('#' + thechosenone).show(600); $.cookie('thechosenone', thechosenone); } jQuery(function($){ var thechosenone = $.cookie('thechosenone'); if(thechosenone){ showonlyone(thechosenone) } }) Demo: Fiddle

Categories : Javascript

How do I make the page refresh in Javascript
setting window.location = ... will refresh the page, but stuff after that will not trigger, because you just refreshed the page including all the javascript. You can put the code you want to trigger in a $(document).ready(function(){your_code_here}); call and when the page refreshes, it will set up your click event.

Categories : Javascript

Refresh the page with javascript and GET variables
Well, what's up with document.write(…) in here? You don't want to print out anything: var email = localStorage.getItem('email'); But if you want to print out the values for testing: var email = localStorage.getItem('email'); document.write(email); (See also console.log(…)) You should escape the parameters using encodeURIComponent(…): location.href = url + "?email=" + encodeURIComponent(email) + "&pass=" + encodeURIComponent(pass); Also you should not use document.write anyhow. There are plenty more reasonable methods to change the content dynamically on you website. You should not send a password using GET requests, as they will appear the browser, proxy and server logs. Use POST requests through invisible forms.

Categories : Javascript

How to extract a list of links from a page in Javascript
Using chrome you could use something like: var list=document.getElementsByClassName('yt-uix-contextlink'); for (i=0;i<list.length;i++) { console.log(list[i].getAttribute("href")); } Paste it in the console tab. This will actually produce 2 links (/watch...) for each video.

Categories : Regex

JavaScript toggle 2 links from full page
Looks like you can simply manage that by adding a CSS class to the elements that were already "selected". Check this simple test I did at JSFiddle: http://jsfiddle.net/L4rUM/1/ // When you click the "?" $('button#btnHelp').on('click', function(){ // Gathers the list of ALL <a> elements that were not "selected" yet var uncheckeds = $('.main .container > a:not(.selected)'); // If you have at least 2 available elements if(uncheckeds.size() > 1){ // Adds the .selected CSS class to first 2 non-selected elements uncheckeds.eq(0).addClass('selected'); uncheckeds.eq(1).addClass('selected'); } }); And the CSS manipulation you are doing is now controlled by just adding the CSS class: .selected { color: #0c0; } I hope this help

Categories : Javascript

possible to refresh (not reload) a parent page with javascript?
If you want to show the newly uploaded image, then the best way is to have a function on parent page like: top.refreshImage = function(url){ $("#<ID_OF_IMAGE_TAG>").attr("src",url); //Or if you are not using jQuery then usual way document.getElementById("<ID_OF_IMAGE_TAG>").src=url; } Then from dialog, after the image is uploaded call this function: top.refreshImage("<URL_OF_NEWLY_UPLOADED_IMAGE");

Categories : Javascript

Refresh page when javascript alert OK is pressed
You could try changing your refreshPage() function to one of these: function refreshPage() { history.go(0); } or: function refreshPage() { document.reload() } Another possible problem might be that you are not calling refreshPage() in the right place. EDIT: Try this: function refreshPage() { window.location.reload() } function myFunction() { var first = confirmDelete(); var second = refreshPage(); return (first && second); } function confirmDelete() { var agree= confirm("confirm?"); if (agree == true) { $result = array(); $result[0] = ('<?php if (isset($_POST['check'])) { if ($queryType == "apps") { $deletePath = "delete/";

Categories : PHP

Javascript Continuous Scroller - speeding up on a page refresh
The following code is now working! I added an if statement and - clearInterval(lefttime); to the initialize marquee function. The code is now consistent on a page refresh, and if it the user selects a submit button that also refreshes the page. <html> <style type="text/css"> #marqueecontainer{ position: relative; width: 1020px; /*marquee width */ height: 30px; /*marquee height */ background-color:#FFF; color:black; overflow: hidden; border: 1px #FFF; padding: 2px; padding-left: 4px; text-align:left; } #marqueecontainer img { border-width:2px; border-style:solid; } </style> <script type="text/javascript"> var delayb4scroll=300 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds) var marqueespeed=1 //Specify marquee scroll speed (la

Categories : Javascript

Looping javascript timer that ignores Web page refresh
Since you (apparently) control the the cron job, and say it executes every full hour, you can use JavaScript to calculate the time difference between now and the next hour. This, of course, relies on the server and visitor having their clocks in sync, as far as minutes/seconds are concerned. Keep in mind that there are time zones with half-hour offsets and the likes. If you want it to be more exact, you'll need to have some server-side logic to store the time/date of the next reset. You can either do it somewhere in your application code, or you could just use the cronjob to write the the time information in a suitable format into your files.

Categories : Javascript

How to update javascript variable value in html without a page refresh
If it's going to update whenever you type into the input, you need an event handler: document.getElementById('num').onkeyup = function() { var a = 1000 + parseFloat(this.value); document.getElementById("test").innerHTML = a || 0; } FIDDLE

Categories : Javascript

Java http client - get page content after refresh from javascript
This isn't a redirect, this is JavaScript in the brower navigating to another page. If the browser can see the other page, so can your application, firewalls and proxies permitting. So your code can simply load the other URL. However, if you mean, given a response containing this piece of JavaScript, how can you programatically run the code in the script element, then that's a whole lot harder. While running JavaScript in Java is straight forward enough using the javax.script API, running it with a complete DOM and handling changes to that DOM is a whole lot harder. While it might be an interesting exercise to write an engine with its own DOM, my advice would be to use an API like the Selenium WebDriver that has already done it for you.

Categories : Java

Using JavaScript, I want to use XPath to look for the presence of a string, then refresh the page based on that
You can flip your selector to a css selector and then use document.querySelector(selector); var xpath = '/HTML[1]/BODY[1]/TABLE[1]/TBODY[1]/TR[3]/TD[1]/TABLE[1]/TBODY[1]/TR[1]/TD[1]/P[1]/B[1]', selector = xpath.replace(//([a-z]+)[([0-9]+)]/gi, function(_, tag, num) { num--; return tag + ':nth-child(' + num + ')>'; }).slice(0, -1); var element = document.querySelector(selector); When you got the element you can use .innerHTML to get the html of the specified node. var mySearch = 'June 20'; if ( element.innerHTML.indexOf(mySearch) == -1 ) { // the string isn't present };

Categories : Javascript

refresh page using javascript (location.reload()) not working on android 2.3.x
location.reload(true); This one worked for me last time. If still not please do reply me. also you might have done something like this .setAppCacheEnabled(true); .setAppCacheMaxSize(1024*1024*8); .setCacheMode(1);

Categories : Javascript

a href Links are wider than they should be
The div with learn class is having a block display so browser will adjust the outer <a> as as display block and occupy the available width. Change div display as inline-block then you can see the width of <a> coming as 215px here is the example code <html> <style> .inside { width: 1014px; margin: 0 auto; overflow: hidden; } #people .learn { display: inline-block; background: url(http://www.domain.com/images/learn.png); width: 215px; height: 51px; margin: 30px 0 0 20px; padding: 0; border:solid 1px ; } </style> <div id="people"> <div class="inside"> <div class="headline"><span class="bold">Best</span> Webhosting Around. Period.</div>

Categories : CSS

jQuery get last visited url in ajax page
I got it working using jQuery(window).on('hashchange', function() { jQuery("body").load(location.href+' body'); }); But there one issue though i need it to call when the url is previous url like location.href==previous url then i need to run the above

Categories : Jquery

Using Cookies to check if someone has visited a page
You can check to see if the cookie is previously set or not before setting it. if( !isset($_COOKIE['firstvisit']) ){ //if the cookie is not set //set your cookie } //skip otherwise

Categories : PHP

Href and mailto links in KnockoutJS
Using the attr and text properties in the data-bind attribute like so: <script type="text/template" id="customerSearchDisplayTemplate"> <tr> <td class = "hiddenId"><span data-bind="text: customerSearchID"/></td> <td><span data-bind="text: fullName" /></td> <td> <span> <a data-bind="text: primaryEmail, attr: {href: 'mailto:'+primaryEmail()}" /> <span/> </td> <td> <span> <a data-bind="text: secondaryEmail, attr: {href: 'mailto:'+secondaryEmail()}" /> <span/> </td> <td><span da

Categories : Knockout Js

Is there a way to tell if an end user will be able to handle links?
As far as I know detecting what capabilities / applications a user has can be tricky for security reasons, but you can rule some things out and go from there. You could try see of its a mobile browser which can handle the link, and then if not, see if the other device is capable of using a telephone number, e.g. Skype, and again if not, just display a normal number. this combines answers from these questions a href tel and standard browsers and Javascript to detect Skype? <div> <?php if(strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'mobile') || strstr(strtolower($_SERVER['HTTP_USER_AGENT']), 'android')) { echo '<div id="tel"><a href="tel:123456">123456</a></div>'; }else{?> <script> function skype (failureFunction) {

Categories : HTML

Loop through all links and find the href
use jQuery.each to loop through more than one. Using your Fiddle: var $hrefs = $('#myLinks').find('a[href]'); var $myDivs = $('#myDivs'); $hrefs.each(function(index,link){ $(link.hash,$myDivs).css('background-color','yellow'); }); You could also use map (fiddle): var hrefs = $('#myLinks').find('a[href]') .map(function(){ return this.hash; }) .get(); $('#myDivs').find(hrefs.join(',')).css('background-color','yellow');

Categories : Javascript

bouncing images with href links
Seems like a trivial old obtrusive script. general solution In function loadBouncingImages2() find where setLayerHTML() is called and change its second parameter to whatever HTML string you need. It could be altered to '<a href="...">'+getImgTag(...)+'</a>'. universal solution replace the setLayerHTML call to var img = getImgTag('bouncingImagesImg' + layerLoop,imagesDetails[layerLoop].src,imagesDetails[layerLoop].width,imagesDetails[layerLoop].height,0); setLayerHTML(imagesDetails[layerLoop].layerObj,'<a href="'+imagesDetails[layerLoop].href+'">'+img+'</a>'); and after that, just modify the configuration by adding href to imageDetails, like imagesDetails[0].href = 'http://www.google.com';

Categories : Javascript

Qr code generates different links with 2 parameters (img != href)
Maybe the mailbox skips the last parameter, it is sometimes hard to predict (gmail alters the HTML). I think you should URL-encode the whole URL, because the character ? might be the cause of the problem. This would be string resetLink = "http://chart.apis.google.com/chart?cht=qr&chs=300x300&chl= http%3A%2F%2Fsite.com%2FAccount%2FValidate%2F%3Fparam1%3D" + model.UserName + "%26param%3D" + model.Token I also replaced the ampersand before chl you encoded by its real character.

Categories : Asp Net Mvc

click multiple href download links
Here's a jquery alternative to what you seek. Window.open should be used for multiple downloads, as window.location will trigger only once in the code run. $('#foo').on('click', function() { window.open($(this).attr("href"),'_blank'); }); $('#foo').trigger('click');

Categories : Javascript

How can I use the CSS before selector for links except those containing an
I believe ur trying to achieve somthing as in this thread,pls check out. jQuery selectors: only link with images inside them

Categories : CSS

colorbox popup not opening after the page visited through turbolink
Try also this openFileForm = -> $(".photobox").colorbox width:"40%" height:"40%" escKey: false overlayClose: false $(document).ready -> openFileForm() $(document).on 'page:load', -> openFileForm()

Categories : Jquery

Bootstrap popover doesn't show href links
Here is the solution to diplay HTML content in the popover. Refer this demo JSFiddle HTML : <button class="btn btn-default" data-placement="bottom" data-toggle="popover" data-container="body" type="button" data-original-title="" data-content='<a href="#">This is link</a><br><a href="#"><b>&quot;This is link 2&quot;</b></a>' data-trigger="click" id="example"> Click to Popover bottom</button> JS: $('#example').popover({ html:true//, //content:'<a href="#">This is link</a>' });

Categories : Twitter



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.