JavaScript - Please Explain This Regex Fragment [^>]*
Please, if you would explain this regex fragment [^>]*
to me. Thank you for reading this post. (I know how to use the ThankYou button ) Similar Tutorials<script type="text/javascript"> function display(action, id) { if (action == 'show') { document.getElementById("explanation"+id).style.display = "block"; document.getElementById("link"+id) = "javascript:display('hide', "+id+")"; } if (action == 'hide') { document.getElementById("explanation"+id).style.display = "none"; document.getElementById("link"+id) = "javascript:display('show', "+id+")"; } } </script> umm Hi i wrote a script with little help from internet but i dont truly understand it, can anyone please explain to me what every line in this script is doing ? im asking polite. var przed="zostalo do urodzin" var obecnie="dzisiaj urodziny" var Tablica=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec") function odliczanie(r,m,d){ theyear=r;themonth=m;theday=d var dzisiaj=new Date() var rok=dzisiaj.getYear() if (rok < 1000) rok+=1900 var miesiac=dzisiaj.getMonth() var dzien=dzisiaj.getDate() var godzina=dzisiaj.getHours() var minuta=dzisiaj.getMinutes() var sekunda=dzisiaj.getSeconds() var dzisiajstring=Tablica[miesiac]+" "+dzien+", "+rok+" "+godzina+":"+minuta+":"+sekunda dataa=Tablica[m-1]+" "+d+", "+r dd=Date.parse(dataa)-Date.parse(dzisiajstring) dday=Math.floor(dd/(60*60*1000*24)*1) dgodz=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1) dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1) dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1) if(dday==0&&dgodz==0&&dmin==0&&dsec==1){ document.forms.count.count2.value=obecnie return } else document.forms.count.count2.value=dday+ " dni, "+dgodz+" godzin, "+dmin+" minut, i "+dsec+" sekund "+przed setTimeout("odliczanie(theyear,themonth,theday)",1000) } odliczanie(2015,1,20) Hi all, First of all, I am not a student and this is not homework. Secondly, I've been programming in C, Motorola assembler, Intel assembler and even GWBasic for years. I recently (this year) got into Web / Javascript / PHP / HTML programming and I'm clawing up the learning curve. I know a fair amount, but have a long way to go. OK here's my problem: I've been trying to integrate a WYSIWYG editor (TinyMCE) into a bulletin board software package (PHPBB3). All is working well except for one big stumbling block that I've been battling for the past MONTH!...: I want to support the original BBCode system of PHPBB3 (mostly because of the ability for the admin to add custom BBCodes). So, what I need to do is this: (1) Select a range of text. (2) Either REPLACE it with "[tag]selection[/tag]" or else INSERT "[tag]" before and "[/tag]" after. (3) Lastly, the original selection must remain selected so that additional BBCodes can be wrapped without the need to re-select. The purpose of (3) is, say, the user clicks "bold" and "italic" and "underline".... all they should have to do is click those 3, not re-select each time. I've tried doing this: (1) get the selection range (2) get the selection text (3) delete the range contents (4) create two "contextual fragments" (one for the opening tag, the other for the closing tag). (5) create a <span> element containing the selection text (6) Insert it all into the range with range.insertNode() (7) finally select the new span element This seems to work fine, but Internet Explorer fails (it complains when I try to get the selection range). I just don't know what I'm doing wrong... and worse I'm not even sure if I'm attacking the problem the proper way. Any ideas would be greatly appreciated! Thanks! -- Roger hi, i would like to know what kind of mechanism does the bolded part trigger Code: G = function(a) { if (i !== a) { var b = i; i = a; for (a = 0; a < A.length; ++a) A[a](b) } } i dont want to know what the function does, just a wild guess, would it be the A array is replaced with functions names? R. i got this code from this thread http://www.codingforums.com/showthread.php?t=241809(THanks to jmrker) and i was wondering if you could explain how it works(The creating textboxes and the randomization). Edit: SOrry i forgot to include the code Code: <!DOC HTML> <html> <head> <title> Untitled </title> <script type="text/javascript"> // From: http://www.codingforums.com/showthread.php?t=241809 var maxSeats = 341; var rndSeats = 10; function randOrd() { return (Math.round(Math.random())-0.5); } function createDisplay() { var seating = [];; var str = ''; for (var i=0; i<maxSeats; ++i) { seating.push(0); } for (var i=0; i<maxSeats; i++) { str += '<input type="text" size="1" id="s'+i+'" value="'+seating[i]+'">'; if ((i % 33) == 32) { str += '<br>'; } } document.getElementById('auditorium').innerHTML = str; } var sarr = []; function randomize() { for (var i=0; i<maxSeats; i++) { sarr[i] = i; } sarr.sort(randOrd); } var tptr; var ptr = 0; function pauseDisplay() { document.getElementById('s'+sarr[ptr]).value = 'x'; document.getElementById('s'+sarr[ptr]).style.backgroundColor = 'red'; if (ptr < (maxSeats-rndSeats)) { ptr++; tptr = setTimeout("pauseDisplay()",250); } } window.onload = function() { createDisplay(); randomize(); tptr = setTimeout("pauseDisplay()",250); } </script> </head> <body> <div id="auditorium"></div> </body> </html> I've been playing with this workarouns for literally years, but I'm getting fed up with it. Can anyone here suggest a better way of dealing with the following conundrum - or at least clarify why it occurs? When I have an external stylesheet I can't access the properties assigned therein. I'll give an example - HTML/CSS/JS are all inseperate files - but everything is called into the HTML as you can see. HTML: Code: <head> <script type="text/javascript" src="js.js"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="box" onclick="showWidth()"></div> <body> CSS (style.css) Code: #box { width: 200px; } Javascript (js.js) Code: function showWidth(){ var box = document.getElementById('box'); alert(box.style.width); } Now the alert fired by showWidth() is empty - meaning that javascript can't see the width of the div element 'box' Now, if I assign width as part of the style attribute of the div javascript thus: HTML: Code: <head> <script type="text/javascript" src="js.js"></script> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="box" onclick="showWidth()" style="width: 200px;"></div> <body> javascript can see this and the alert fired by showWidth() shows '200px'. So, I have two questions: 1. Why? 2. Is there a way of accessing these external style elements without having to define styles inline all the time? Cheers! Mike I tried a a few tutorials but still can't get it, can any simply closures please?
So today I learned about the ()'s for functions so I was like always studying and I cannot understand how this snippit works, here it is. Quote: var say = function(what) { what('say function'); } var hello = function (who) { alert('Hello '+who); // outputs "Hello say function" } say(hello); So the say(hello); is activating the function. The (hello) should be passed for (what) so the function(who) is now inside the other or something? Can someone please list steps like 1-10 of how this code ends up saying "Hello say function" at the end? thank you so much <script type="text/javascript"> var myString = "zero one two three four"; var mySplitResult = myString.split(" "); for(i = 0; i < mySplitResult.length; i++){ document.write("<br /> Element " + i + " = " + mySplitResult[i]); } </script> "split" function splits the string whenever it encounters "space". But please explain me how the strings are stored in "mySplitResult". And can we use Arrays for this program? If so, can you code it. Thanks in advance! So I had the orginial code just switch images, I was under the impression I could use "var clientData" to make an array. However this is not working out the way I had hoped. Any help or explanation, greatly appreciated. It's very sloppy now! Don't judge. Here is my Javascript: Code: <script type="text/javascript"> var imgList = [ "../Assets/Images_Revised/40_kitchen.jpg", "../Assets/Images_Revised/40_stair.jpg", "../Assets/Images_Revised/C_front2.jpg", "../Assets/Images_Revised/C_rear_side_combo.jpg", "../Assets/Images_Revised/C_side.jpg", "../Assets/Images_Revised/Y_combo.jpg", "../Assets/Images_Revised/Y_window.jpg" ]; var clientData = [ "This is Data for Client 1"; "This is Data for Client 2"; "This is Data for Client 3"; "This is Data for Client 4"; "This is Data for Client 5"; "This is Data for Client 6"; "This is Data for Client 7" ]; var currentMain = 0; var currentMainT = 0; function Prev() { return ShowMain(currentMain-1); return ShowMainT(currentMainT-1); } function Next() { return ShowMain(currentMain+1); return ShowMainT(currentMainT+1); } function ShowMain(which) { currentMain = which; currentMainT = which; if ( currentMain < 0 ) currentMain = 0; if ( currentMainT < 0 ) currentMainT = 0; if ( currentMain > imgList.length-1) currentMain = imgList.length-1; if ( currentMainT > clientData.length-1) currentMainT = clientData.length-1; document.getElementById('mainImg').src = imgList[currentMain]; document.getElementById('mainText').src = clientData[currentMainT]; var PD = document.getElementById('Pg'); var PD2 = document.getElementById('Pg2'); if (PD != null ) PD.innerHTML = 'Image '+(currentMain+1)+' of '+imgList.length; if (PD2 != null ) PD2.innerHTML = (currentMainT+1)+' of '+clientData.length; return false; } onload = function() { ShowMain(0); } onload = function() { ShowMainT(0); } </script> Here is my area I am showing it. Code: <a href="#" onclick="return ShowMain(0); return ShowMainT(0)">1</a ><a href="#" onclick="return ShowMain(1); return ShowMainT(1);">2</a ><a href="#" onclick="return ShowMain(2); return ShowMainT(2)">3</a ><a href="#" onclick="return ShowMain(3); return ShowMainT(3)">4</a ><a href="#" onclick="return ShowMain(4); return ShowMainT(4)">5</a ><a href="#" onclick="return ShowMain(5); return ShowMainT(5)">6</a ><a href="#" onclick="return ShowMain(6); return ShowMainT(6)">7</a ><a href="#" onclick="return Prev();" class="gallery"><</a ><a href="#" class="gallery" onclick="return Next();">></a> <span id="mainText">Click on a Client for Information.</span> Hi, I am hoping a JS expert might be able to explain this function. It is part of a larger programme. The program basically checks which profile the user selects and sets the html to display in certain colours. I am still trying to understand programming. The part I don't understand is the SetCookie("profile", i); What is this function telling the SetCookie function to do? Why does this work? Really grateful for any info.Thanks in advance. ************************************************* function updateProfile() { for (var i=0;i<document.form1.profile.length;i++) { if (document.form1.profile[i].checked) { SetCookie("profile", i); } } document.location="cookie3.html"; } OK, I work for a company that accepts donations. Currently, the donation page looks nothing like the rest of the site. So I recreated the page to look like the rest of the site. But when I do so, Chrome shows it as a "security risk". Someone looked at it and told me that it's because the .js files aren't compressed and the browser considers this a security risk. So how do I compress the files? overImg=[];outImg=[]; outImg[0]=new Image();outImg[0].src="images/enter1.gif"; overImg[0]=new Image();overImg[0].src="images/enter2.gif"; outImg[1]=new Image();outImg[1].src="images/keio.gif"; overImg[1]=new Image();overImg[1].src="images/inria.gif"; function chgImg(img,type){ switch(type){ case "over":document.images[img].src=overImg[img].src;break; case "out":document.images[img].src=outImg[img].src;break; }} why are arrays used here ? PHP Code: <script type="text/javascript"><!--//--><![CDATA[//><!-- sfHover = function() { var sfEls = document.getElementById("nav").getElementByClass("subMenuWrapper"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover); //--><!]]></script> Im trying to get the sub navigation to work in ie 6 but can get it working.. can anybody tell me what the above funtion does and how i might be able to apply it to my code... the navigation i have so far is on http://www.corkdesigns.ie/ep3/testing.html Hope someone can help or is the a simple hack i can use for ie 6 for this navigation http://www.corkdesigns.ie/ep3/navigation1.html Thanks I am trying to understand what this javascript function is trying to accomplish. Can anyone breifly describe what the function is doing? If you can do a break down that would be great for me to understand this a bit better. I apreciate any assistance! Code: /* Engagement Score */ s.eVar5=s.engagementScore('event31','s.pageName|products|1>s.events|event6|1>s.eVar3|competitiveMatrix.pdf|1>s.pageName|webLeadsForm:complete|1>s.events|purchase|1>s.events|event4|1>s.events|scView|1'); /* Engagement Score Tracking */ s.engagementScore = new Function("e","l","c",""); var A,B,C,D,E,F,G,H,I,J; I=J=''; A=s.split(l,'>'); B=A.length; E=c?c:'s_ES'; //D=value of cookie with name 'E' D=s.c_r(E); if(!D){ for(C=0;C<B;C++){ D=D+'0,'; } } D=s.split(D,','); for(C=0;C<B;C++){ F=s.split(A[C],'|'); G=eval(F[0]); if(D[C]==1){ I=I+'1,'; } else if(G!=undefined){ if(G.indexOf(F[1])>-1&&D[C]!=1){ s.events=s.apl(s.events,e,',',2); s.products=s.apl(s.products,';;;;'+e+'='+F[2],',',2); I=I+'1,'; J='+'+F[2]; } else { I=I+'0,'; } } else{ I=I+'0,'; } } s.c_w(E,I,0); return J; s.split=new Function("l","d",""+"var i,x=0,a=new Array;while(l){i=l.indexOf(d);i=i>-1?i:l.length;a[x"+"++]=l.substring(0,i);l=l.substring(i+d.length);}return a"); The Js code is used for lightbox picture gallery.. THe code works perfectly in IE and Firefox but not in chrome Can any body explain the js in this html file and explain how i can get it to work in chrome... Thanks PHP Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><!-- InstanceBegin template="/Templates/new.dwt" codeOutsideHTMLIsLocked="false" --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- InstanceBeginEditable name="doctitle" --> <title>Bouncing Castles Cork, Bouncy Castles Cork, Cork Bouncing Castle, Djs for Kids Parties in Cork</title> <!-- InstanceEndEditable --> <!-- InstanceBeginEditable name="EditRegion3" --> <meta name="Description" content="Bounce Castles Cork for Bouncy Castles in Ireland, Irish Inflatable Games, Bouncy Castle Rentals and Inflatable games for events around Ireland, entertainment and leisure industry throughout Ireland."/> <meta name="Keywords" content="Bouncing Castles Cork, Bouncy Castles Cork, Cork Bouncing Castles, Cork Bouncy Castle, Childrens entertainment adult entertainment, Cork festivals Fun fairs Fun days " /> <link href="css/style.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="swfobject.js"></script> <script type="text/javascript"> var flashvars = {}; flashvars.settingsXML = "settings.xml"; var params = {}; params.scale = "noscale"; params.salign = "tl"; params.wmode = "transparent"; var attributes = {}; swfobject.embedSWF("dockmenu.swf", "dockmenuDiv", "600", "200", "9.0.0", false, flashvars, params, attributes); </script> <link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" /> <script src="js/prototype.js" type="text/javascript"></script> <script src="js/scriptaculous.js?load=effects" type="text/javascript"></script> <script src="js/lightbox++.js" type="text/javascript"></script> <script type="text/javascript"> function GroupDelegate(id) { var objLink = document.getElementById(id); Lightbox.prototype.start(objLink); } </script> <!-- InstanceEndEditable --> </head> <body> <!-- main wrap starts here --> <div id="main-wrap"> <!-- header starts here --> <div id="header"> <h1><a href="../index.html">Dream Bouncing Castles</a></h1> </div> <!-- header ends here --> <!-- menu container starts here --> <div id="menu-container"> <ul> <li><a href="../index.html">Home</a></li> <li><a href="#">Bouncing Castles</a></li> <li><a href="#">DJs for kids Parties</a></li> <li><a href="../contact.html">Contact us</a></li> </ul> </div> <!-- menu container ends here --> <div class="clear"></div> <!-- body container starts here --> <div id="body-container"> <div id="banner_boy_wrapper"> <div id="banner"></div> <div id="boy"></div> </div> <!-- InstanceBeginEditable name="EditRegion4" --> <!-- welcome container starts here --> <script type="text/javascript"> var xmlDoc; var numitor; if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); numitor=1; } else if (document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); numitor=2; } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; var xmlFile = "images.xml"; xmlDoc.load(xmlFile); var x=xmlDoc.documentElement.childNodes; for (var i=0;i<x.length;i++) { if (x[i].nodeType==1) document.write("<a id='img",(i+1)/numitor,"' href='", x[i].getAttribute("bigimage"),"' rel='lightbox[img]' title='", x[i].getAttribute("lightboxInfo"), "'></a>"); } </script> <div id="welcome-container"> <h2>Our Bouncing Castles</h2> <p>Below you can see all the bouncing castles we hire out</p><br /> <div id="dockmenuDiv"> <a href="http://www.adobe.com/go/getflashplayer"> <img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /> </a> </div> </div> <!-- welcome container ends here --> <div class="clear"></div> <!-- bouncy container starts here --> <!-- bouncy container ends here --> <!-- InstanceEndEditable --> <div class="clear"></div> </div> <!-- body container ends here --> <!-- footer starts here --> <div id="footer"> <a href="../index.html">Home</a> | <a href="#">Bouncing Castles</a> | <a href="#">Djs For Kids Parties</a> | <a href="../contact.html">Contact Us</a><br /> Copyrights 2009. All Rights Reserved </div> <!-- footer ends here --> <div class="clear"></div> </div> <!-- main wrap ends here --> </body> <!-- InstanceEnd --></html> Hello I am new to javascript and have the following question: Is it normal that the Document.links property only counts links that are placed before the command? example: Code: <body> <script type="text/javascript"> document.write (document.links.length); </script> <p><a href="http://www.youtube.com/watch?v=gt9j80Jkc_A#">Youtube link</a></p> <script type="text/javascript"> document.write (document.links.length); </script> </body> The result is Quote: 0 Youtube link 1 How can I avoid this? Only by putting the code at the end of the document? And since i am asking? Is it possible to search a entire document for a string and replace that string with one command? (don't give me exact solution please just a hint what direction i should be searching in). Kind regards Hi - if you click on any of these radio boxes an effect happens whereby content is pushed down. Can you tell me what causes this? http://www.emailcraft.com/order-now.html The reason I ask is because I am after this effect and am looking for someone to code it for me - but am not sure how to describe it - thanks a lot Find it really hard to understand these random variable names and what they are doing, can anyone explain what is going on exactly in the bolded parts. I have a rough idea but the 3 arrays confuse me somewhat im sure the random variable names are pointers and counts but id love to hear an expert explain them for sure thanks if you can help or are willing to take the time Hello, I'm taking Computer Logic in college. I only am truly familiar with HTML and CSS and minimal web hosting stuff. I REALLY want to learn how to program, however. Anyway, we are doing classes/objects and functions. I am trying to figure out how to do this exercise. She starts with having us make this page that has a form that lets you select one of three radio buttons that will change the background color of the web page, along with that there is two text boxes to put a first name and last name. Then there is a button to click which puts your full name concatenated in another box below. All of this, is done, and I pretty much THINK I understand what is going on. Here is the code that we did to get this to happen: Code: <html> <head> <title>Computer Logic in class</title> <script type="text/javascript"> var nextColor = ""; var BR = "<br />"; function setColor(newColor) { nextColor = newColor; } function changeColor() { document.body.bgColor = nextColor; } function displayName() { var firstName = document.ColorAndText.firstName.value; var lastName = document.ColorAndText.lastName.value; document.ColorAndText.fullName.value = firstName + " " + lastName; } </script> </head> <body bgcolor="red"> <form name="ColorAndText" action = ""> <input type="radio" name="colors" value="Blue" onclick="setColor(this.value)"/> Blue <br /> <input type="radio" name="colors" value="LightYellow" onclick="setColor(this.value)"/> Light Yellow <br /> <input type="radio" name="colors" value="Yellow" onclick="setColor(this.value)"/> Yellow <br /> <input type="button" name="changeButton" value="changeColor" onclick="changeColor()" /> <br /> <input type="text" name="firstName" value="First Name" size="40" /><br /> <input type="text" name="lastName" value="Last Name" size="40" /><br /> <input type="text" name="fullName" readonly="true" size="40" /><br /> <input type="button" name="displayButton" value="Display name" onclick="displayName()" /> <br /> </form> </body> </html> Okay, now, I have and can do that. Seems to make sense. Now, then, the actual program I need to make is from the following exercises: Activity 3-4 The owner of a flower shop wants you to develop a form for use on the shop's web site. The form should have a single text box for the user to enter his or her name. Under the text box should be a group of radio buttons for three different kinds of flowers: Roses, Carnations, and Daisies. Below the radio buttons should be a button labeled Request Info, with a read-only text box under it for thanking the user for requesting information. This program doesn't need any functions or onclick attributes for the graphical elements. Okay, here is the code that does that, very simple HTML. Code: <html> <head> <title>Computer Logic in class</title> <script type="text/javascript"> var nextFlower = ""; var BR = "<br />"; function setFlower(newFlower) { nextFlower = newFlower; } function displayMessage() { var firstName = document.Flowers.nameBox.value; document.Flowers.fullName.value = firstName + "," + nextFlower; } </script> </head> <body bgcolor="white"> <form name="Flowers" action = ""> <input type="text" name="nameBox" value="Namebox" size="60"><br /> <input type="radio" name="flowers" value="Roses" onclick="setFlower(this.value)"/> Roses <br /> <input type="radio" name="flowers" value="Carnations" onclick="setFlower(this.value)"/> Carnations <br /> <input type="radio" name="flowers" value="Daisies" onclick="setFlower(this.value)"/> Daisies <br /> <input type="button" name="displayButton" value="Request Info" onclick="displayMessage(this.value)" /> <br /><br /> <input type="text" name="thankyou" readonly="true" size="100" value="Thanks for using this program" /> </form> </body> </html> Okay, now is where I'm stuck. The following exercise is as follows: The flower shop owner in the previous activity wants to see where you can make the form interactive and asks you to have the form display a message in the bottom text box that includes the user's name, a comma, and the words "thank you for your inquiry about" followed by the flower name the user selected. Write a function named displayMessage() that accesses the user's name from the first text box and displays the message in the read-only text box. You also need to make the Request Info button call the displayMessage() function when it's clicked. Using Javascript, make this form active by including event triggers and functions. My teacher has said that I should be able to do this by just referencing these two previous pages of code that I have already pasted. I feel like I am missing something, that I need to be doing something and it's just not working for me. I'm actually really really stuck on this. I haven't even gotten to the second half of the exercise (where I have to have it display about what flower you select) because I cant get this function to work. What am I missing? Also, the exercise we did before these two had us make a very basic account class and object. We don't have to do that at all in this anywhere, but I do know how to do it, in case I need to make a class or something. ANY AND ALL HELP GREATLY APPRECIATED!!! I just don't know what I'm supposed to do, I can't get it to work. |