w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Javascript hyperlinks don't work with jQuery append
Without seeing what data may contain its difficult to see exactly what you're trying to achieve but I can see the fist thing you do after receiving the ajax response is overwrite the returned data which is obviously incorrect. perhaps you meant something like this?: $.get("content1.php", {id:"1234" }, function(i,data) { var link = '<a href="someotherpage.php?var1='+data.var1+'&amp;var2='+data.var2+'">link</a>'; $('.div_content').append(link); });

Categories : Javascript

Jquery Highlight Active Link works for Href links but not Menu Items
You need to get the Menu client id when you get it on client. Try using the following code snippet: <script type="text/javascript"> $(document).ready(function () { var url = window.location.href; url = url.substr(url.lastIndexOf("/") + 1); $("#" + "<%= NavMenu.ClientID %>").find("a[href='" + url + "']").addClass("selected"); }); </script>

Categories : Jquery

Add an 'active' class to all active links in rails?
This is a good case for writing your own helper that wraps the link_to. In your application_helper.rb you can write a method active_link_to that takes the same params as link_to + current_page, and then just calls link_to like you are doing above.

Categories : CSS

jQuery menu which is switching a blocks below + links to active blocks
This gets the hash (#) and looks for the div with the ID that matches the hash. if(window.location.hash){ var whichDiv = window.location.hash; $(whichDiv).show(); } You need to edit these so that the hash matches the ID of the paragraph (removed the /): <li><a id="linkOne" href="#first">First</a></li> <li><a id="linkTwo" href="#second">Second</a></li> <li><a id="linkThree" href="#third">Third</a></li>

Categories : Jquery

how to get the content which is pasted using jquery
Try this $("#textarea").on('keyup paste', function(e) { clearTimeout($(this).data('timeout')); $(this).data('timeout', setTimeout(function(){ alert(e.target.value); }, 200)); }); EXAMPLE note: changed bind to on which is preferable.

Categories : Jquery

Using Javascript, is it possible to upload images along with text pasted from other web pages/clipboard?
To answer your question, yes, it is possible to upload images and text, you may just need to parse the images' urls etc. As for your implied question, "can I get images and text pasted from the clipboard:" Only in IE. JS doesn't allow access to clipboard data for security reasons (except in IE). You can't get the data in an element.onpaste event either; according to MDN (https://developer.mozilla.org/en-US/docs/Web/API/element.onpaste): "There is currently no DOM-only way to obtain the text being pasted; you'll have to use an nsIClipboard to get that information."

Categories : Javascript

Copy and pasted Microsoft example of Javascript to check value in cell, but fails to work
The key lays on the variable "ewa". Normally when the page loads, inside loadEwaOnPageLoad() there is this line: Ewa.EwaControl.loadEwaAsync(fileToken, "myExcelDiv", props, onEwaLoaded); So we need to grab an Ewa object inside the onEwaLoaded function. I saw it somewhere like this (ewa declared somewhere else): function onEwaLoaded(asyncResult) { /* * Add code here to interact with the embedded Excel web app. * Find out more at http://msdn.microsoft.com/en-US/library/hh315812.aspx. */ if (asyncResult.getSucceeded()) { // Use the AsyncResult.getEwaControl() method to get a reference to the EwaControl object ewa = asyncResult.getEwaControl(); //... After you got the ewa object the rest would be fine. Without i

Categories : Javascript

Textarea is taking lot of time to validate text when pasted from notepad using RegExp in javascript
This is probably because the regexp goes into a loop. Try to find a simpler regexp that terminates faster in case of an error. Look into *? or validate the text in pieces by first matching part of the regexp (the header). If there is no header -> error. Then strip the header. Search the rest of the input for the inverse of the allowed characters ([^...allowed chars...]. If you have a match anywhere -> error

Categories : Javascript

jQuery/JavaScript Active link in my script - bad underline
If you are trying to make only one button active when it is clicked. $(function(){ $("li input").on( "click", function(e) { $(this).addClass("active").siblings().parent().find('input').removeClass("active"); }); }); And also you have a typo in your css code snippet. It should be : .active{ text-decoration:underline; } If you want some element remain active upon a page refresh then you can simply add the "active" class on html markup as : <li><input type="button" onClick="Clock(0)" value="MADRID" name="MADRID" class="active" /></li> on whatever list item's input you want

Categories : Javascript

JQuery/javascript: Dynamic gallery's images can be used as links but not as buttons. Why?
You need to prevent the default click behavior the plugin is trying to fire. $("#monja").click(function(e) { e.preventDefault(); alert('it works'); }); For more info as to how this works, check out Event Bubbling.

Categories : Javascript

Processing a String and replacing al URL's with working links via Java
public String transformURLIntoLinks(String text){ String urlValidationRegex = "(https?|ftp)://(www\d?|[a-zA-Z0-9]+)?.[a-zA-Z0-9-]+(\:|.)([a-zA-Z0-9.]+|(\d+)?)([/?:].*)?"; Pattern p = Pattern.compile(urlValidationRegex); Matcher m = p.matcher(text); StringBuffer sb = new StringBuffer(); while(m.find()){ String found =m.group(0); m.appendReplacement(sb, "<a href='"+found+"'>"+found+"</a>"); } m.appendTail(sb); return sb.toString(); } m.group(1) was the mistake. m.group(0) works. This will transform any URL found in the text into an anchor.

Categories : Java

Perl: Replacing links (html) that meet certain criteria
I'd use a regex gobal and eval flag for callback, eg like so: #!/usr/bin/perl use strict; my $internal_link = qr'href="https?://(?:www.)?myforum.com'; my $html = ' Lorem ipsum <a href="http://www.external1.com" target="_blank">External Link 1</A> Lorem ipsum <a href="http://www.myforum.com">Local Link 1</A> Lorem ipsum <a href="http://www.external2.com">External Link 2</A> Lorem ipsum <a href="http://www.myforum.com/test" ALT="Local">Local Link 2</A> '; $html =~ s/<a ([^>]+)>/"<a ". replace_externals($1). ">"/eg; print $html; sub replace_externals { my ($inner) = @_; return $inner =~ $internal_link ? $inner : "$inner rel="nofollow""; } Alternatively you can surely use negative look-aheads, but that would just m

Categories : Regex

javascript image slider hyperlinks
Use a plugin like Nivo Slider (that way you don't really need to develop the jQuery from scratch), and then wrap the image in an anchor tag <a>: <div id="slider"> <img src="images/thing.jpg" alt="No Link" /> <a href="http://www.cnn.com"><img src="images/thing2.jpg" title="Link!" /></a> </div>

Categories : Javascript

Adding hyperlinks to index array in javascript
I don't know what problems you had with .push() but this should work: mypic[0].push("<a href='link.html'>I am a link</a>"); And of course the same can be done with mypic[1].

Categories : Javascript

jquery confirm dialog with hyperlinks
warningString = "<p style='margin-top: 15px;'>Please Verify the following URL is a valid Redirect URL.</p> <br/><a href='" + redirURL + "'>" + redirURL + "</a>";

Categories : Jquery

javascript tabular function how to add active class to active button
If you just want to add or remove class, you can use $(this).addClass('active') or $(this).removeClass('active'). Assuming the if statement is working in the code as intented, following code should work. if (this.pathname == window.location.pathname) { showcont.push(this); showcont_containers.push($(this.hash).get(0)); this.addClass('active'); }; With the following code you can add "active" class to the <a> element you click, and remove it from the siblings. $('#tabs ul li a').on('click', function() { $(this).addClass('active').siblings().removeClass('active'); }); This however won't work if you are refreshing page after every <a> element click.

Categories : Jquery

simple horizontal menu with active links
Create an active class for your links (just add the class to your :hover CSS): #menu a:hover, #menu a.active { .... } Now you you have links like: <a href="#" class="active">Link</a> Was that the question?

Categories : HTML

Active admin default links only for certain users
So I figured this out. It wasn't too bad, I just had to go about the problem differently. Just add this method to application_controller.rb def require_can_download_for_csv raise unless current_admin_user.can_download? end And then add this to your active_admin initializer: config.before_filter :require_can_download_for_csv And that's it!

Categories : Ruby On Rails

Dynamically Bound TextBlock Links Not Active until Clicked
Well, it's hacky but it was the only thing that seemed to work. I sent a KeyUp (down arrow) to the application and all is good. [DllImport("user32.dll")] public static extern void keybd_event(byte bVk, byte bScan, uint dwFlags, uint dwExtraInfo); and then in the textchanged handler at the end. textBlock.Inlines.Clear(); textBlock.Inlines.AddRange(inlines); keybd_event(0x28, 0, 0x0002, 0); There's something about the application having to see an input event allows the it to recoginize the textblock has been with new wpf controls.

Categories : Wpf

Find active links parent and clone nested ul
here is the solution I found: $('ul.nav a.active').parent().children('ul').clone().appendTo('.leftnav').removeClass(); I found the active a Then found its parent which was an li Then I looked in the li's children and found the ul I was then able to clone that ul and append it to the leftnav div

Categories : Jquery

How to programmatically add active style to header control links using C#?
Just add a public property to the user control. I assume this data is in a data structure when your page is initialized. The property type should be of the appropriate type to identify that data. Then when the page is rendered, the control should take the value of the property into consideration for how the data is rendered. This might involved setting runat=server for each list item and then setting the CssClass property for the appropriate one. I personally took a different approach, writing the raw code to generate the HTML. I can think of other options as well. An example of the first approach might look something like this (untested): ascx <ul> <li id="HomeList" runat="server">Home</li> <li id="AboutList" runat="server">About</li> <li

Categories : C#

CSS3 transition only applying to active link, and not all links
You have incorrect selector if you need all of the links to have transition. It should be: body .main-nav li >a, body .main-nav li >a:visited You have .active-link in your selector which exists only to the link of the page you are on.

Categories : CSS

make parent links display active class when sub menu link is selected
First create a variable to see if the menu item is selected and put it on false. Set it to false in its main menu loop at the start. Then before printing the menu item to the screen loop over the submenu items, create a string with the submenu and check if one of them is on the current page. If one is the current page set the selected variable to true. After the submenu loop you will have a variable that holds if the menu item should have an additonal class and can you create the item with the submenu. Edit <div id="cssmenu"> <ul> <li <?php if($_GET["id"] == '') { echo 'class="active"'; } ?>><a href="/home.php><span>Homepage</span></a></li> <?php //select all the top row items $sql="SELECT * from website_menu where parent_top

Categories : PHP

Top Drawer Navigation Menu Toggle push content down and display active links
Add in $('.menu').click(function(e){ $('.drawer').toggleClass('active'); e.preventDefault(); }); http://jsfiddle.net/RFpDJ/1/

Categories : Jquery

Vertical navigation with sub menus with image up and down links for each level with active link highlight when on selected page
Issue #1: The text gets smaller in the sub-menus because you have this rule #nav ul.menu ul.sub-menu > li , #nav ul.menu ul.sub-sub-menu > li { ... font-size:0.7em; ... } while the default for the first level items is #nav ul.menu > li { ... font-size:0.9em; ... } Either remove the font-size decalaration for the submenus or set the value to inherit Issue #2 I couldn't test this since I don't have your images so I'm not sure if this is what's causing the problem but it seems you're missing the > a at the end of this CSS rule selector #nav ul.sub-menu > li > a, #nav ul.sub-sub-menu > li { background: transparent url('../../second-third-categories-with-submenus.png'); ... } Issue #3 To highlight the menu items you can just set

Categories : HTML

Detecting if browser window is active and start event after window is active again [JavaScript]
I think the problem is that when you click a link the second time the window will always be focused. JS runs pretty fast. To overcome this, I think you should do a setTimeout() and delay it 200ms or so to give the window time to "lose" focus setTimeout(function() {userOnWebsiteOrNot(); },2000); http://jsfiddle.net/xVHgE/ Edit: Adding delay to event listener. I don't think you can "delay" an event though, just the function it runs. window.addEventListener('focus', function() { setTimeout( function() { $('#test').html('focus'); focusedOrNot = 0; } , 5000); });

Categories : Javascript

Bootstrap Scrollspy randomly adds and remove "active" class to navbar links when scrolling if modal is linked to in a navbar link
For my implementation, simply changing the tag/class and adding boostrap styles to the new class worked, as Scrollyspy looks for .nav li > a. Granted, in my case, having the active effect wasn't needed since the modal pops up. This seemed a lot quicker and cleaner to me but might not be the solution to everyone's styling and functionality specific issue.

Categories : HTML

Replacing or removing javascript
Wrap pulls all of that HTML out of the page and sticks it in HTML built from the param for wrapAll and then you stick the whole bundle back on the page which means you're slapping that same script file back onto the page I assume. Any time a script tag is dropped into a page, all of its JS executes. Now I'm going to edit and make some other suggestions when I've figured wtf is going on with this app but that's your problem with the bonus firing. Additional: Okay, so I don't know what Smarty is. Whenever I see a Smarty-related question, something horrifying is going on so I don't even want to know. If you have any control over the app in general, you should be able to add Script tags before jQuery happens. Ideally before this tag gets appended. At the very least, add an empty function cal

Categories : Javascript

Replacing ${...} in javascript string?
Modifying the answer from the question you linked, you can capture part of the match (only the name) and use that as the key: var str = "My name is ${name} and I like ${sport} because ${sport} is challenging."; var mapObj = { name:"Bob", sport:"soccer" }; str = str.replace(/[$]{([^{}]+)}/g, function(match, key){ return mapObj[key]; }); The second argument to the anonymous function will be filled with what was matched inside the first pair of parentheses in the pattern (i.e. what was matched by [^{}]*). Of course, you should add some sanity check that your key is actually present in the map. Alternatively, use the approach from the other question and just list the allowed names in the pattern: /[$]{(name|sport)}/g

Categories : Javascript

Replacing the last character in a string javascript
Simple regex replace should do what you want: checkbox_data1 = checkbox_data1.replace(/.$/,1); Generic version: mystr = mystr.replace(/.$/,"replacement"); Remember that just calling str.replace() doesn't apply the change to str unless you do str = str.replace() - that is, apply the replace() function's return value back to the variable str

Categories : Javascript

replacing commas with slashes in JavaScript
document.getElementById('val') should be document.getElementById('one') If you make this change you don't need to send this to removeComma. If you keep this then use the following function function removeComma(val) { var values = val.value; var n=values.replace(/,/, "/"); val.value=n; }

Categories : Javascript

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#

Replacing all instances of a value in JSON using pure JavaScript
You can try this var jsonObject = JSON.parse(yourJSONString); for(var i = 0, len = jsonObject.savedSearches.length; i < len; i++) { jsonObject.savedSearches[i].version = "Number you want here"; } If you, for some reason, want to return a string: JSON.stringify(jsonObject) If you already have the object, you can skip the JSON.parse

Categories : Javascript

Replacing words and phrases in string - Javascript
var a = "Apple Book "Grand Piano" Piano Pear"; var b = "Piano"; var c = "Grand Piano"; var regexp = new RegExp('('+b+')|('+c+')', 'g'); a = a.replace(regexp, ''); You need to do all the replacements simultaneously, with a regexp that matches everything you need to exclude. Make sure to escape your strings before adding them to the RegExp if it's needed.

Categories : Javascript

replacing text between two strings in javascript using greasemonkey
The easiest way to do this would be with a regular expression. var comment = "[youtube]http://www.youtube.com/embed/XGSy3_Czz8k[/youtube]", match = comment.match(/[youtube]([^[]*)[/youtube]/); if (match) { var iframe = document.createElement("iframe"); iframe.src = match[1]; document.body.appendChild(iframe); }

Categories : Javascript

Replacing Phone Numbers on Page with Javascript
Because you're passing the string on to create a regular expression, you need to escape the parenthesis: p('888-888-8888','(999)-999-9999'); p('\(888\)-888-8888','(999)-999-9999'); p('\(888\) 888-8888','(999)-999-9999'); Another way would be to use a single pattern: p('(888-|\(888\)[- ])888-8888','(999)-999-9999');

Categories : Javascript

javascript replace() is not replacing all the characters match
Use a regex with the g flag. var $id = id.replace(///g, '_');

Categories : Javascript

Replacing string queries in URL's with Javascript (conditional)
Use location.search to toggle the query parameter and refresh the page. It will also minimize your javascript a ton, see below: function gridclick(){ location.search = "mode=grid"; } function listclick(){ location.search = "mode=list"; } UPDATE: Actually to make it even more efficient I'd modify your code to the following.. HTML: <img src="images/grid.png" width="18" height="18" alt="Grid view" onClick="toggleView('grid')"/> <img src="images/list.png" alt="List view" width="18" height="18" onClick="toggleView('list')"/> And just have one function handling your view toggle. Javascript: function toggleView(view){ location.search = "mode=" + view; }

Categories : Javascript

Replacing DIVs jQuery
The problem is that favs and rest are actually references to the divs, and if you change the text within them, the reference remains the same, so when you go to pick up the text later, it isn't what it was when you first iterated it. So you replace "Game 1" in #game1 with "Game 4 (fav)", and you have a reference to it in rest[0]. When you then try to process rest, the text of rest[0] is "Game 4 (fav)". The solution is to push the text values instead of DOM references. $(document).ready(function(){ var favs = []; var rest = []; var items = $('.row > div'); items.each( function() { if ( $(this).hasClass('fav') ) { favs.push( $(this).text() ); } else { rest.push( $(this).text() ); }

Categories : Javascript

Javascript Math Replacing Dots/Decimals with Commas
I would recommend using the Globalize library. It allows you to do globalization of numbers easily. The following example is taken from the documentation page and shows to output a number using a specific culture: Globalize.culture( "en" ); Globalize.format( 1234.567, "n" ); // "1,234.57" Globalize.culture( "nl" ); Globalize.format( 1234.567, "n" ); // "1.234,57" - note that the comma and dot are switched I have created a small sample project that shows how to use this library for client-side globalization: https://github.com/ErikSchierboom/clientsideglobalization

Categories : Javascript



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