JavaScript - Single Link Extraction
I've been looking for a client side Link Extraction script. I've found plenty that extract all links from the desired site, but I'm looking for one to just grab a specific link with a variable hash. Has anyone ran across something like this?
Any info you may have would be great! Thanks! Similar TutorialsHi-- I have a link that has an mp3 sound as its href: Code: <a href="sounds/genealogy.mp3" class="track track-default">this is a link</a> Unfortunately, I also need that same link to go to a part on the site (href=#greenhouse) so that the sound plays on that part of the site. Does anyone know how to accomplish this? I am imagining it would be with javascript, but honestly, I do not know. Any help would be greatly appreciated. Many thanks...! Hi All, Below is a block of data. I'm trying to figure out how to extract text from the block. As you will see, some lines will have answers, some will not. I thought about using split, however not every line has the same delimiters (eg. $), and I am unsure how to apply 2 different splits per line, the only constant is that every line has a line feed at the end. E.g: YourPersonTitle$Title : Mr In the example above, I need to pull out everything between $ and line feed, so the result is: Title : Mr basically, any line with an answer needs to be returned. There would be a maximum of about 100 lines. I am currently reading a primer on regular expressions, but would appreciate some help or a point in the right direction. Code: YourPersonTitle$Title : Mr YourPersonTitle$OtherTitle : YourPersonalDetails$Surname : Citizen YourPersonalDetails$FirstName : Joe YourPersonalDetails$OtherNames : YourPersonalDetailsDOB : 1.11.1900 YourPostalAddress$Address : 2 Road Street, Sydney YourPostalAddress$State : NSW YourPostalAddress$Postcode : 2200 YourPhoneEmail$HomePhone : 9999 7777 I have a .c file with many function calls like, say, "ABC ( x, y, z);" My concern is to extract just the function name ABC. My approach is to read the file using streamreader.ReadToEnd(), and find the function name using regular expression \b\w+(\([a-z]*[0-9]*\)\b\w). the function call may be of the form... ABC ( xab, ybc, zbc, hgs );" i.e. the syntax is spread thru multiple lines. in the end i just want the function name ABC. please help me with the regular expression or if there is any other approach. Thank U Hi Can you please advise on this. When writing javascript what is best practice.... single or double quotes? I tried to research this and everyone contracdicts each other? thanks A I am looking for a way to add multiple items with a single URL to my shopping cart. any ideas? cheers, How can I add single quotes around listObj.options[i].value. I still want to keep the comma I'm adding to the end of it. Code: CSV += listObj.options[i].value + ','; Having problems with IE not displaying the page correctly with I hide <li> I have commented out the lines that are messing up the display, can anyone tell me how I correctly hide the <li> tags ? Code: <div class="innerformboxes"> <!-- misc start --> <ul> <li class="<? if ($empty_Field == "paymentMethod") {?>emptyfield<? } else { ?>field<? } ?>"> Payment Method * </li> <li class="value"> <select name="paymentMethod" onChange="if(this.value == 'Other') { document.getElementById('altpaymentMethodDiv').style.display='block'; } else { document.getElementById('altpaymentMethodDiv').style.display='none'; document.getElementById('altpaymentMethod').value=''; };"> <option value="">Select Payment Method</option> <option <? if($paymentMethod == 'Cash') { echo 'selected'; } ?> value="Cash">Cash</option> <option <? if($paymentMethod == 'Credit Card') { echo 'selected'; } ?> value="Credit Card">Credit Card</option> <option <? if($paymentMethod == 'Account') { echo 'selected'; } ?> value="Account">Account</option> <option <? if($paymentMethod == 'Other') { echo 'selected'; } ?> value="Other">Other</option> </select> </li> <!-- <div < ? if($paymentMethod == 'Other') { echo 'style="display: block;"'; } else { echo 'style="display: none;"'; } ?> id="altpaymentMethodDiv"> --> <li class="<? if ($empty_Field == "altpaymentMethod") {?>emptyfield<? } else { ?>field<? } ?>"> Other <input type="text" autocomplete="off" name="altpaymentMethod" id="altpaymentMethod" value="<?=$altpaymentMethod;?>" style="width: 200px;"> </li> <!-- </div> --> <? if(!isSet($_SESSION['FM_user'])) { ?> <li class="<? if ($empty_Field == "previousClient") {?>emptyfield<? } else { ?>field<? } ?>"> Are you a Previous Client * </li> <li class="value"> <input type="radio" name="previousClient" value="Yes" <? if($previousClient == 'Yes') { echo 'checked'; } ?>> Yes <br> <input type="radio" name="previousClient" value="No" <? if($previousClient != 'Yes') { echo 'checked'; } ?>> No </li> <? } ?> </ul> <!-- misc end --> </div> I am trying to make a JavaScript chat-bot I was using this to answer a month questions and it worked fine for what is the month after DatesA=new Array("january,February","february,March","march,April","april,May","may,June","june,July","july,Aug ust","august,September","september,October","october,November","november,December","december,January "); if (input.search("what is the next month after")!= -1) {document.result.result.value = "Sorry, I don't know."; for (i=0; i<DatesA.length; i++) { Date=DatesA[i].split('='); if (input.search(Date[0]) != -1) { document.result.result.value = Date[1];} } return true;} What is the month after May answer: June however it didn't with letters. Is there a way to write this to prevent the wrong single letter and small words from triggering Letterbefore=newArray("b=a","c=b","d=c","e=d","f=e","g=f","h=g","i=h","j=i","k=j","l=k","m=l","n=m", "o=n","p=o","q=p","r=q","s=r","t=s","u=t","v=u","w=v","x=w","y=x","z=y"); Then use this: if (input.search("what is the letter before")!= -1 || input.search("what letter comes before")!= -1) {document.result.result.value = "Sorry."; for (i=0; i<Letterbefore.length; i++) { Letter=Letterbefore[i].split('='); if (input.search(Letter[0]) != -1) { document.result.result.value = Letter[1];} } return true;} . The bot correctly answers for x y and z . It then answers V for all other letters, digits and short words What is the letter before cow answer: V Thank you for your time Hello , everyone. Was wondering if you can put a single popup that could appear to many visitors to a site at the same time , regardless of the page you 're browsing . Is there a chance to do it in JavaScript or another language ? How could i do it? Iappreciate the help .
Hello I have a rather complicated issue I need to discuss. Due to the nature of what I specialize in it's pretty difficult to discuss with anyone my thoughts. My work involves making GUI's for IPTV set-top-boxes. I both design and implement the user interfaces, which involves doing heavy JavaScript programming (actually it involves creating a framework). How it works in a nutshell is; a browser runs on the set-top-box. When a user presses buttons on the remote controls the browser receives those events as e.g. "UP", "DOWN", "OK", "PROGRAM_UP", "PROGRAM_DOWN", etc. events. They need to be handled by a custom javascript code. But here's where the problems begin. Ordinary web interfaces can depend on the mouse (or finger on touchscreens) for context, the user can press any button anywhere on the interface without a hassle. In TV interfaces you don't have that touchscreen ability, you have to manage some sorts of state/context of what the user is doing and where the user has it's "selection", and decide what to do next if he presses any other buttons, like "OK". The user can be zapping channels with PROGRAM_UP and PROGRAM_DOWN remote control buttons, or the user can be browsing movies by selecting poster with arrow keys and rent with OK. I have to manage this context in JavaScript, handle the input events and modify model/view accordingly. This feels awkward, or wrong. So, that's why I am here. What would you do, if you were given a set-top-box, with Opera/HTML5 support, and the only input is a stateless remote-control. Ideas? Hi all, i was trying to create a windows startup javascript where i was trying to perform a specific action after a time interval. Could anybody please help me with the syntax to add this timer to my js file thanks in advance I'm having a problem with one of my Labs and My TA is not answering emails. I need to make a button, that when you click it, turns the bgColor blue, when you click it twice, it turns bgColor yellow, and a third time turns it orange. The tricky part is, I need to use an internal CSS style sheet for the color, and a function for the javascript. Here is what I have so far, but I'm completely stuck. Code: <html> <head> <style type="text/css" media="all"> highlight {background-color:yellow;} </style> <script type="text/javascript"> function blue() { document.bgcolor = blue; } </script> </head> <body> <p>Good morning. In less than an hour, aircraft from here will join others from around the world..... </p> <input type="button" value="Push me to change color!" onclick="document.bgColor= 'blue'"> </body> </html> (I cut out the doctype for readability) Obviously I'm not utilizing the function.. I tried replacing 'blue' with blue() (which is the name of the function) but that didn't work.. So how I utilize both the function, and the CSS sheet, AND get the button to do consecutive actions onClick..? -Thanks, this is my first post, I hope everything is understandable. I am completely new to javascript programming. We had another company (out of business now) develop a mapping system that placed many different business locations on a Google map. However, the points overlap and hide each other. I would like the user to have to single click on the map (thus zooming the map in) before they can choose a business. Is there a simple line of code that will do this? I want to remove the need to double click to zoom and make it a single click to zoom prior to selecting a business. If you want to see the mapping code, I can post it. I wasn't sure what to do. This is a fairly pressing matter as the nonprofit I am helping out is seasonal and ready to start the busy season soon. THANKS! Hi there, I have this listbox that I want the user to select only one choice at a time. How do I disable the multiple selection feature in javascript? <select id="lstBxEmail" name="listBoxEmail" multiple="multiple" style="width: 580px;"> <option>Java</option> <option>PHP</option> <option>Perl</option> <option>Javascript</option> <option>C#</option> <option>Powershell</option> </select> <select id="lstBxEmail" name="listBoxEmail" multiple="multiple" style="width: 580px;"> <option>Java</option> <option>PHP</option> <option>Perl</option> <option>Javascript</option> <option>C#</option> <option>Powershell</option> </select> Hi , I have a data coming as a string which contains single quotes and double quotes but it is showing up as Code: ' and " it should show it as Code: ' and " How do I fix this issue. in JavaScript. Can someone help me I am trying to get these two values, firstname and lastname to both go into the same output box on a form. I want them to show up alongside one another like so nameform.output2.value=firstname + " " + lastname; but the values are assigned within seperate if statements as you can see below.. so I dont know how to get them to merge.. I am kinda new with javascript so any help will be very useful. Thakns very much. Code: function checkform(nameform){ var firstname=new Array(); firstname[0]="johndefinition"; firstname[1]="jamesdefinition"; var lastname=new Array(); lastname[0]="smithdefinition"; lastname[1]="simpsondefinition"; if (document.getElementById("namebox").value.indexOf("John")!=-1) {nameform.output2.value= firstname[0];} if (document.getElementById("namebox").value.indexOf("James")!=-1) {nameform.output2.value= firstname[1];} if (document.getElementById("namebox").value.indexOf("Smith")!=-1) {nameform.output2.value=lastname[0];} if (document.getElementById("namebox").value.indexOf("Simpson")!=-1) {nameform.output2.value=lastname[1];} } I currently am using a mootools popup on www.Hope1st.com to play his music videos.....and its working really well...only thing is on some computers (mac with firefox browser) when someone pauses the video ...the draggable box gets stuck on their mouse weird right? yea i know... so i thought of a solution...instead of the whole box being draggable why not just the black titlebar be draggable? i have absolutely no idea on how to do this....but i do have the entire JS code....are you ready? its a mouthful....a million thanks to whoever is talented enough to help me Code: var mooSimpleBox = new Class({ options: { width: 300, height: 200, opacity: '0.8', btnTitle: "Ok", closeBtn: null, boxTitle: "messageBox", boxClass: 'mainBox', id: 'myID', fadeSpeed: 500, box: null, addContentID:null, addContent: null, boxTxtColor: '#000', isVisible: false, isDrag: true }, initialize: function(options){ this.isVisible = false; if(options['isDrag']) this.isDrag = options['isDrag']; if(options['width']) this.width = options['width']; if(options['height']) this.height = options['height']; if(options['opacity']) this.opacity = options['opacity']; if(options['btnTitle']) this.btnTitle = options['btnTitle']; if(options['boxTitle']) this.boxTitle = options['boxTitle']; if(options['boxClass']) this.boxClass = options['boxClass']; if(options['boxTxtColor']) this.boxTxtColor = options['boxTxtColor']; if(options['fadeSpeed']) this.fadeSpeed = options['fadeSpeed']; if(options['id']) this.id = options['id']; if(options['closeBtn']) this.closeBtn = $(options['closeBtn']); if(options['addContentID']) this.addContentID = options['addContentID']; if(options['addContentID']) { this.addContent = $(this.addContentID).innerHTML; $(this.addContentID).setStyle('visibility','hidden'); $(this.addContentID).remove(); } this.createBox(); }, createBox: function(){ this.box = new Element('div'); this.box.addClass(this.boxClass); }, clickClose: function(){ $(this.box).effect('opacity',{ wait:true, duration:this.fadeSpeed, transition:Fx.Transitions.linear }).chain(function(){ }).start(this.opacity,0); this.box.setStyle('display','none'); this.isVisible = false; }, fadeOut: function(){ if(this.isVisible){ $(this.box).effect('opacity',{ wait:true, duration:this.fadeSpeed, transition:Fx.Transitions.linear }).chain(function(){ }).start(this.opacity,0); this.isVisible = false; } }, fadeIn: function(){ if (document.documentElement && document.documentElement.clientWidth) { theWidth=document.documentElement.clientWidth; }else if (document.body) { theWidth=document.body.clientWidth; } if (window.innerHeight) { theHeight=window.innerHeight; }else if (document.documentElement && document.documentElement.clientHeight) { theHeight=document.documentElement.clientHeight; }else if (document.body) { theHeight=document.body.clientHeight; } var top = window.getScrollTop(); var boxTop = (theHeight - this.height) / 2 ; boxTop = (boxTop + top); var boxLeft = (theWidth - this.width) / 2; this.box.setStyle('top',boxTop); this.box.setStyle('left',boxLeft); this.box.setStyle('position','absolute'); this.box.setStyle('width',this.width); this.box.setStyle('height',this.height); this.box.setStyle('opacity',this.opacity); this.box.setStyle('cursor','move'); this.box.setStyle('z-index','999990000'); this.box.setAttribute('id', this.id); this.box.setStyle('visibility','hidden'); this.box.injectInside(document.body); if(this.isVisible == false){ this.box.effect('opacity',{ wait:true, duration: this.fadeSpeed, transition: Fx.Transitions.linear }).start(0,this.opacity); this.addHT(); this.isVisible = true; } }, addHT: function(){ this.closeBtn = new Element('button', { styles: { 'border': 'none', 'background-image':'url(modules/mod_moopopup/moopopup/images/bg_button.gif)', 'color':'#fff', 'position':'absolute', 'bottom':'3px', 'right':'3px', 'width':'44px', 'height':'19px', 'font-size':'13px', 'font-weight':'bold', 'font-family':'arial', 'cursor':'pointer' } }) var width = this.width.toInt() + 5; if(window.ie){ var titleBar = new Element('div', { styles: { 'width' : width, 'height': 'auto', 'background-repeat': 'repeat-x', 'background-position': 'right top', 'line-height': '20px', 'padding': '5px 5px 5px 10px', 'position': 'absolute', 'clear': 'both', 'margin-bottom': '10px', 'top': '0px', 'left': '0px', 'color': '#eee' } }) }else{ var titleBar = new Element('div', { styles: { 'width' : width, 'height': 'auto', 'background-repeat': 'repeat-x', 'background-position': 'right top', 'line-height': 'auto', 'padding': '5px 5px 5px 10px', 'position': 'absolute', 'clear': 'both', 'margin-bottom': '10px', 'top': '0px', 'left': '0px', 'color': '#eee' } }) } $(titleBar).innerHTML = this.boxTitle; var insideDiv = new Element('div',{ styles: { 'padding':'10px' } }); insideDiv.setAttribute('id','myContent'); this.box.innerHTML = ""; insideDiv.injectInside(this.box); insideDiv.innerHTML = this.addContent; this.closeBtn.innerHTML = this.btnTitle; $(this.closeBtn).addEvent('click',this.clickClose.bindWithEvent(this)); titleBar.injectInside(this.box); this.closeBtn.injectInside(this.box); if(this.isDrag == 'true'){ this.box.makeDraggable(); } } }); mooSimpleBox.implement(new Options, new Events); Hello folks, I have a very simple problem...but stuggling with this. I have a popup window (.aspx page). It will called from a parent .aspx page. All I want to do is read the name of the parent aspx page in popup page. Based on the name of the parent window, in the page_load event of the popup window, I want to execute some code. But the only catch is that, I am not able to read the parent window name until the page_load event (of popup window) complets the execution. 1. calling popup window from parent window. Code: Code: function OpenWindow_HistoricalRuns() { var windowIncsimHistRuns = window.open('MVal.aspx', 'Market', 'width=350,height=425,scrollbars=0'); windowIncsimHistRuns.moveTo(500, 300); } In the body of the popup window the following function tries to read the parent window name: Code: function SetDisplay() { document.getElementById('<%=TextBoxSourcePageName.ClientID%>').value = window.parent.name; } In the page_load event of the popup window, I want to see what is value of TextBoxSourcePageName control. I hoped I will get 'MarketVal'. But I never get anything. Code: protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { try { if (TextBoxSourcePageName.Text == "MarketVal") } } } In my situation, I need to know the window.parent.name by the time Page_load event gets triggered on the popup window. Because I have to do some specific thing in the Page_Load event (of popup window), based on window.parent.name. So my fundamental question is, which one will get fired first in an .aspx page. 1. Javascript in the body tag or 2. Page_load event of the .aspx page. If Javascript function in the body tag gets fired first, then by the time I get to Page_Load event, I should already have whatever I need. thanks |