JavaScript - Need Help With A Very Special Redirect...
Hello,
I need to improve an existing JavaScript redirect by adding a second redirect based on information contained in the URL. First I will outline the situation, then the specifics: I designed a Realtor website using Joomla 1.5 a few years ago. I will call this SITE-1. The site, SITE-1, displays real estate listing from another site (SITE-2) using iFrames. So the listings from SITE-2 appear to be integrated into the pages of SITE-1. Someone shopping for real estate signs up to be notified of new listings. A new listing comes out and an email is sent to the user with a link to the listing - only the link to the listing is located on SITE-2. So I have been using a JavaScript redirect on SITE-2 that asks the question - "is this in an iFrame" ... if no - redirect to SITE-1 and iframe the results. SITE-1 is ready to receive and parses the new URL: Code: <script language="JavaScript"> <!-- // Start if (window == top) { tops = top.location.href location.replace('http://www.SITE-1.com/index.php?option=com_content&view=article&id=42&Itemid=137&iframe='+tops); } // End --> </script> Now, I have a new problem. I don't have access to SITE-2, I only get to submit a template to them. One of the possible links sent to users from SITE-2 contains a variable in the URL: &id=, followed by a 3 digit number. So the full URL might look like this: http://www.site-2.com/index.php?pg=delacct&id=570 I cannot redirect this to the normal page on SITE-1 because Joomla already uses id=, and it just gets confused and drops a 404 page. Instead I need the code I posted above, to FIRST check for id=. If it exists - go to PAGE-A. If not - then do what the script already does as posted above (we'll call that PAGE-B). Can anyone help? (hopefully I explained that so it can be understood) Thanks, --Kevin Similar TutorialsHello, this is only for specialist in javascript. I searching a very special javascript, which can be done expire a web site after some identified time(i.e 10days, 20days....). I have made a web site. now i'm looking for, the site expire(or not working at hosting) within 10 days. can I find any special javascript like this? In Brno, 07.06.2011 Hello everybody, i really need your help with one issue. I have got one page running under Wordpress and i would like to add some countdown to widget to show when i will be again online. for example: I am online every working day (monday - friday) from 08:00 AM to 04:30 PM. So it would be nice to show to my subscribers when i would be online again. So lets think about that is Thuesday 07:00 PM, so on my page would be visible this: "I will be back in 13 hours, 00 minutes, 00 seconds" Or in Saturday at 07:00 PM there will be written: "I will be back in 37 hours, 00 minutes, 00 seconds" I would really apreciate every help, thank you in advance! Stefan alias "Scharfheimlich" I am trying to make a page that shows a daily special for a *fake* pizza place. I want it to detect the day it is, and write the special within the document as an H1 heading or something like that. For testing I have it setup to do an Alert, but it alerts me of the monday special today which is correct, but if I change my system time to another day it doesn't work. Does it work like that or is there a better way to test it? Here is the code, there is a <body onload="getToday()"> in place Code: function getToday() { var d = new Date(); var weekday=new Array(7); weekday[0]="Sunday"; weekday[1]="Monday"; weekday[2]="Tuesday"; weekday[3]="Wednesday"; weekday[4]="Thursday"; weekday[5]="Friday"; weekday[6]="Saturday"; if (weekday[d.getDay()] = 0) { alert("Buy one Pizza get a second for only $5"); } else if (weekday[d.getDay()] = 1) { alert("Order of Breadsticks for $1"); } else if (weekday[d.getDay()] = 2) { alert("Order of Cinnamon Sticks for $1"); } else if (weekday[d.getDay()] = 3) { alert("Free Two Liter with Pizza Order"); } else if (weekday[d.getDay()] = 4) { alert("Order of Hot Wings for $1"); } else if (weekday[d.getDay()] = 5) { alert("Orders of Breadsticks, Cinnamon Sticks, and 2 liter for $3 with"); } else if (weekday[d.getDay()] = 6) { alert("Breadsticks and a two liter for $1"); } } </script> I am trying to make a very simple form so a user can enter some text then be redirected to a page that uses that text in the URL. So far I have this working using window.open but the ? and & in the URL show up as & # 0 3 8 ; here is the code in the body; Code: <script type="text/javascript"> /* <![CDATA[ */ function orderBlog() { var subDomain = document.blogDomain.domainEntered.value; window.open("http://mydomain.com/portal/cart.php?=add&pid=15&domainoption=subdomain&sld=" + subDomain + ""); } /* ]]> */ </script> <form name='blogDomain' onsubmit="orderBlog();"> <input type='text' name='domainEntered' size='60' style='width:100px;' /> .mydomain.com <input type="submit" value="Get Your Site!" /> </form> but for some reason that goes to the URL mydomain.com/portal/cart.php & # 0 3 8 ; =add & # 0 3 8 ; pid=15 & # 0 3 8 ; domainoption=subdomain & # 0 3 8 ; sld=XXXXXXXX when using firfox, ie7 works fine hi, I would like to change my validation page so that a user cannot use special characters in the form, here is my code below Code: jQuery("#full_name").validate({ expression: "if (VAL) return true; else return false;", message: "Please enter your name" }); jQuery("#name").validate({ expression: "if (VAL.match(/^[^\\W][a-zA-Z\\_\\-\\.]+([a-zA-Z\\_\\-\\.]+)*\\@[a-zA-Z0-9_]+(\\.[a-zA-Z0-9_]+)*\\.[a-zA-Z]{2,4}$/)) return true; else return false;", message: "Please enter your name" }); HELLO FELLAS, can someone please show me where get drop down menu like the one goldman sachs uses. take a look please: http://www2.goldmansachs.com/ help is much appreciated julio First of all thanks for all the help you are providing. I am looking to alert a user if they type in an character that I am going to not allow for their input box Code: function IsExc (str){ var AllChr = "~ # $ % ^ { } [ ] ' ,"; var AC= AllChr.split(" "); var SC = 0; for (SC=0; SC <= AC.length; SC++){ var ACS = AC[SC]; if (str.search(ACS) >0 ) alert ('Cannot use the characters' + AllChr ) } } For reasons I don't understand the code will not work Hey. Yes, I'm just starting at the beginning and what I'm trying to understand today is adding special characters such as line break, quotes, etc. into Javascript. I'm missing something, however. Can someone please assist? What I'm trying to do is add a line break without having it show /n on the screen. My Code: <html> <head> <title>Exercise 6-20</title> </head> <body><pre> ********* *** * *\n * * * * *** * *\n * * * * ***** * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n * * * * * * *\n ********* *** * * *\n </pre> </body> </html> Thank you, H Hallo. I am a total newbie to JavaScript coding, but I would like to have a price calculator on our internal website. It should calculate the square meter of the product and then multiply it with the square meter price, multiply it with quantity and then plus it with the startup cost. But... if the square meter extend 20 m2 the square meter price should be lower, and also lower when it hit 50 m2. And at 100 m2 it should write that you have to contact sales department. Can this be done with JavaScript? Here is an example: 6 pieces of 2 x 4 meter. 2x4 = 8 m2 6x8 = 48 total m2 48 m2 x price2 x startup = total price I really hope that someone can help me... //Daniel I am trying to get a series of dynamic digits from page one to page two via the url. below are the codes have been able to come up with. The problem am having however is that the variables from the first page contains two other characters mainly (=) and (on). therefore, the result i get is like this; 2=on43=on6=on76=on98=on34=on etc What i want displayed are simply the numbers without these two characters. Code: <script> if(window.location.search){ var query = window.location.search.substr(1); var data = query.split("&"); for (var i = 1; i <= 9; i++){ var data = datas[i].split("="); if (unescape(data[1]) == key_str); data.replace(/\=/g," "); } } </script> below is the code that writes the output Code: <script> for (i = 1; (i <= 9); i++) { document.write(data[i]); data[i]="" } </script> thanks Hi guys (and ladies) I am a bit stuck and hope this community might shine a light, or even better can supply me with a solution. I want to do the following: - Having an ordinary webpage containing links - I will link the links with files (word processing files , MS Word, Open Office writer, wordpad or similar) - Now when clicked on the link I want the 'system' to copy the contents of the linked file to the windows clipboard, so when clicking paste, the text from the file is pasted wherever I want. To make clear, I don't want any word processing app to open, just click the link and paste where it needs to be. Possible?? MOST LIKELY but I have no clue how. Any chance someone might know the answer??? I am looking forward to the replies! Thanks PvL Hi I have downloaded the code to allow special html characters in <textarea> be replaced with the actual code so it does not cause problem when the text is submitted into the database. For example '>' to be replaced with '>' So for a string ' 3 > 2' I expect to be replaced with '3 > 2; in the text box. However it does not work. I put in the alert statements and it shows that the js function is being invoked, but after the function is done, the special characters in the text box remain the same. Can someone help? <html> <header> </header> <body> <script language="javascript"> function html2entities(){ var re=/[(<>"'&]/g for (i=0; i<arguments.length; i++) alert("check char"+ arguments[i].value); arguments[i].value=arguments[i].value.replace(re, function(m){return replacechar(m)}) } function replacechar(match){ if (match=="<") return "<" else if (match==">") return ">" else if (match=="\"") return """ else if (match=="'") return "'" else if (match=="&") return "&" } </script> <form> Data 1 <textarea name="data1" style="width: 400px; height: 100px"></textarea><br /> <input type="button" onClick="html2entities(this.form.data1)" value="Convert special chars to entities"> </form> </body> </html> This code is a bit full on, but it works in IE. I am not suspecting the document.write part, but can anyone tell me why this code fails in Firefox? I think it might be the focus parts in red. Is it not right for FF? Code: function Flash1(tickerstring){ var speedText='<html><head><title>Flashcards - Speed 1</title><script>var sTickString="'+tickerstring+'"</script><script src="flasher(AC).js" language="JavaScript1.2"></script><script>var timeOutVal=300;</script></head> <body onLoad="self.focus()" onBlur="self.focus()"> <a href="javascript:parent.window.focus();top.window.close()"><p align="right"><font face="Arial" color="#808080" size="1"> <i>Close Window</i> </font><p></a><hr><div id=\"bottom_section\"> <\/div>'; function NewWindow(mypage,myname,w,h){ LeftPosition=(screen.width)?(screen.width-w)/2:100; TopPosition=(screen.height)?(screen.height-h)/2:100; settings='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=no,menubar=no,toolbar=no,directories=no,location=no,resizable=no,status=yes'; win=window.open(mypage,myname,settings); win.document.write(speedText); win.document.close(); if(win.focus){win.focus();} win.refresh; } NewWindow('popup.html','flashcards','620','140'); } Is there an inbuilt function in javascript to convert web characters like
Code: & back to '&' for use in a search text field? http://mybestmaterial.blueeyedpandahosting.com/cep/1/ Works exactly as expected (and all the code is built into the source code view of the page.) What happens is 2 timers are set up. 1 is running when user clicks the Start/Stop link. The second is started when the user clicks the Laughter Start/Stop link. So the sequence should be User -- Start click then after that -- laughter-start-stop click... You will see both timers start running. The laughter click will be clicked multiple times as the app is designed to time how much laughter a comedian or speaker is getting relative to the amount of time on stage. So click the laughter start stop multiple times before clicking the START-STOP the last time. Then a PAR score is generated - which is a simple percent of the time laughter happened, vs the time on stage. The link above works like a charm. THE PROBLEM is -- on my SPRINT TREO 700p --- when I click the laughter start/stop click it stops all the timers. I think for some reason the TREO won't allow the second NEW DATE() to be declared or something... because when I comment those two lines out --- line 166 and 167 in Dreamweaver version of the file -- (if you copy full source into dreamweaver...) Then the clicking doesnt' stop the main timer -- but it also doesn't work!! ANY THOUGHTS on how to decloare the SCOPE fo the NEW DATE() so it only effects that one function? OR any other suggestions? Code pasted below Code: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Comedy Analyzer - Simple</title> </head> <script type="text/javascript"> var flagclock = 0; var flagstop = 0; var stoptime = 0; var currenttime; var splitdate = ''; var output; var clock; function startstop() { //var startstop = document.getElementById('startstopbutton'); var startdate = new Date(); var starttime = startdate.getTime(); if(flagclock==0) { flagclock = 1; counter(starttime); } else { if(laughter_flagclock==1) { laughter_startstop(); } flagclock = 0; flagstop = 1; splitdate = ''; //total laughter === running_total_laughter_time; //total time == running_total_time; var par_score = (Math.round(running_total_laughter_time/running_total_time*100))/100; var par_score_percent = par_score*100; //var par_score = running_total_laughter_time/running_total_time; laughter_output.value = "PAR SCORE = " + par_score_percent; } } var running_total_time; function counter(starttime) { output = document.getElementById('output'); clock = document.getElementById('clock'); laughter_output = document.getElementById('laughter_output'); currenttime = new Date(); var timediff = currenttime.getTime() - starttime; if(flagstop == 1) { timediff = timediff + stoptime } if(flagclock == 1) { clock.value = formattime(timediff,''); running_total_time = timediff; refresh = setTimeout('counter(' + starttime + ');',10); } else { //start and stop the running counter while adding the values to the next deal. window.clearTimeout(refresh); stoptime = timediff; } } function formattime(rawtime,roundtype) { if(roundtype == 'round') { var ds = Math.round(rawtime/100) + ''; } else { var ds = Math.floor(rawtime/100) + ''; } var sec = Math.floor(rawtime/1000); var min = Math.floor(rawtime/60000); ds = ds.charAt(ds.length - 1); if(min >= 60) { startstop(); } sec = sec - 60 * min + ''; if(sec.charAt(sec.length - 2) != '') { sec = sec.charAt(sec.length - 2) + sec.charAt(sec.length - 1); } else { sec = 0 + sec.charAt(sec.length - 1); } min = min + ''; if(min.charAt(min.length - 2) != '') { min = min.charAt(min.length - 2)+min.charAt(min.length - 1); } else { min = 0 + min.charAt(min.length - 1); } return min + ':' + sec + ':' + ds; } function resetclock() { if(flagclock == 1) { //alert("if side of reset clock"); var resetdate = new Date(); var resettime = resetdate.getTime(); counter(resettime); } else { //alert("ELSE side of reset clock"); clock.value = "00:00:0"; } flagstop = 0; stoptime = 0; splitdate = ''; laughter_resetclock(); window.clearTimeout(refresh); output.value = ''; } </script> <script type="text/javascript"> var laughter_flagclock = 0; var laughter_flagstop = 0; var laughter_stoptime = 0; var laughter_currenttime; var laughter_splitdate = ''; var laughter_output; var laughter_clock; var count = 0; function laughter_startstop() { var laughter_startdate = new Date(); var laughter_starttime = laughter_startdate.getTime(); if(laughter_flagclock==0) { laughter_flagclock = 1; laughter_counter(laughter_starttime); laughter_number_text = document.getElementById('laughter_number'); count++; laughter_number_text.value = count; } else { laughter_flagclock = 0; laughter_flagstop = 1; laughter_splitdate = ''; } } var running_total_laughter_time; function laughter_counter(laughter_starttime) { laughter_clock = document.getElementById('laughter_clock'); laughter_currenttime = new Date(); var laughter_timediff = laughter_currenttime.getTime() - laughter_starttime; if(laughter_flagstop == 1) { laughter_timediff = laughter_timediff + laughter_stoptime } if(laughter_flagclock == 1) { laughter_clock.value = laughter_formattime(laughter_timediff,''); running_total_laughter_time = laughter_timediff; //laughter_output.value += "-- laughter -- "+running_total_laughter_time; laughter_refresh = setTimeout('laughter_counter(' + laughter_starttime + ');',10); } else { window.clearTimeout(laughter_refresh); laughter_stoptime = laughter_timediff; } } function laughter_formattime(laughter_rawtime,laughter_roundtype) { if(laughter_roundtype == 'round') { var laughter_ds = Math.round(laughter_rawtime/100) + ''; } else { var laughter_ds = Math.floor(laughter_rawtime/100) + ''; } var laughter_sec = Math.floor(laughter_rawtime/1000); var laughter_min = Math.floor(laughter_rawtime/60000); laughter_ds = laughter_ds.charAt(laughter_ds.length - 1); if(laughter_min >= 60) { laughter_startstop(); } laughter_sec = laughter_sec - 60 * laughter_min + ''; if(laughter_sec.charAt(laughter_sec.length - 2) != '') { laughter_sec = laughter_sec.charAt(laughter_sec.length - 2) + laughter_sec.charAt(laughter_sec.length - 1); } else { laughter_sec = 0 + laughter_sec.charAt(laughter_sec.length - 1); } laughter_min = laughter_min + ''; if(laughter_min.charAt(laughter_min.length - 2) != '') { laughter_min = laughter_min.charAt(laughter_min.length - 2)+laughter_min.charAt(laughter_min.length - 1); } else { laughter_min = 0 + laughter_min.charAt(laughter_min.length - 1); } return laughter_min + ':' + laughter_sec + ':' + laughter_ds; } function laughter_resetclock() { //alert("laughter_resetclock called"); if(laughter_flagclock == 1) { var laughter_resetdate = new Date(); var laughter_resettime = laughter_resetdate.getTime(); laughter_counter(laughter_resettime); } else { laughter_clock.value = "00:00:0"; } laughter_flagstop = 0; laughter_stoptime = 0; laughter_splitdate = ''; count = 0; laughter_number_text.value = count; window.clearTimeout(refresh); laughter_output.value = ''; //window.clearTimeout(refresh); output.value = ''; } </script> <body> Running Time :: <input id="clock" type="text" value="00:00:0" style="text-align: center;" size="14"readonly><br /> Laughter Time :: <input id="laughter_clock" type="text" value="00:00:0" style="text-align: center;"size="14" readonly><br /> Laugh Count :: <input id="laughter_number" type="text" value="0" style="text-align: center;" size="4" readonly><br /> <div id="start_button"><a href="javascript:startstop();">Timing Start/Stop</a></div> <div id="laughter_start_button"><a href="javascript:laughter_startstop();">Laughter Start/Stop</a></div> <textarea id="laughter_output" style="height: 90%;" cols="40" rows="1"></textarea><br /> <a href="javascript:resetclock();">Full-Reset</a><br /><br /> </body> </html> I want to remove special characters in form fields. It should be automatic. I have a name filed where user entering text and i not want special characters, it should remove automatic. something like this i need, Code: onkeyup="javascript:this.value=this.value.replace(/[^0-9]/g, '');" here, all non-digits get removed automatic. Need help. I want to insert "mu" character after "Output in <here i want to insert mu character> " in following JavaScript line Code: paper = new Raphael(document.getElementById('dialog2'), 500, 500); var a= paper.text(345,384,"Output in <here i want to insert mu character> ").attr({'font-size':13}); |