JavaScript - Help Request
I'm not a programmer, just a lowly photographer that manages some websites. A company that provides Print-on-Demand services for me has some code that works in most browsers, but not in IE (at least older versions). It has to do with an onClick routine, and after some google searchs, I saw that similar issues have been common for years. Yet I didn't really understand the solutions. I put up a test page with the relevant code snippet. In Chrome, if one clicks on the image, the sales page comes up. In IE, nothing happens. I gathered that any error will bog down IE. If someone recognizes the problem or knows of a solution, I would be most grateful. The example page is here.
The code snippet is below. Thanks in advance for anyone taking the time to look. <img src='http://images.fineartamerica.com/images-medium-large-5/autumn-peak-at-oxbow-bend-greg-norrell.jpg' style='position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; border: none; z-index: 0;''> <div onTouchEnd='javascript: if(tap){window.location="http://photoartresource.com/featured/autumn-peak-at-oxbow-bend-greg-norrell.html";}' onClick='javascript: window.location="http://photoartresource.com/featured/autumn-peak-at-oxbow-bend-greg-norrell.html";' style='position: absolute; width: 100%; height: 100%; background-color: transparent; z-index: 1;'> </div> Similar TutorialsCan someone modify the code below to save name & email to a file named logfile.dat please? Code: <html> <HEAD> <SCRIPT language="JavaScript"> function WriteFile(name, email) { var fso = new ActiveXObject("Scripting.FileSystemObject"); var fh = fso.CreateTextFile("D:\\logfile.dat", true); fh.WriteLine(name); fh.WriteLine(email); fh.Close(); } function sendtopage(whatpage) { alert(whatpage) window.location.href =whatpage; return true; } redirectTime = "3000"; redirectURL = "http://www.cnn.com"; function timedRedirect() { alert('Thank you'); setTimeout("location.href = redirectURL;",redirectTime); } function getCookie(c_name) { var i,x,y,ARRcookies=document.cookie.split(";"); for (i=0;i<ARRcookies.length;i++) { x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("=")); y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1); x=x.replace(/^\s+|\s+$/g,""); if (x==c_name) { return unescape(y); } } } function setCookie(c_name,value,exdays) { var exdate=new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); document.cookie=c_name + "=" + c_value; } function checkEmailCookie() { var email=getCookie("email"); if (email!=null && email!="") { alert("Email: " + email); } } function checkNameCookie() { var name=getCookie("name"); if (name!=null && name!="") { alert("Name: " + name); } } </SCRIPT> <style type="text/css"> .Class01 { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; font-size: 24px; font-weight: bold; } .Class02 { font-size: 36px; font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } .Class013 { font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif; } .Class01 .Class013 .Class01 { font-weight: bold; } .Classzz { font-family: "Lucida Console", Monaco, monospace; } .Classxx { font-weight: bold; font-size: 24px; } .Classzz { font-family: "Lucida Console", Monaco, monospace; } .style1 { text-align: center; } </style> </HEAD> <body gcolor="#FFFFFF" background="../MCM-background.jpg"> <center> <p class="style1"><img src="../mcm_header2.gif" alt="Header" width="790" height="199"></p> </center> <p></p> <form name="fm" action="http://www.meadecountymessenger.com"> <div align="center"> <p> </p> <p><span class="Class01"><span class="Class02">Please enter the following.</span></span></p> <p> </p> <p><span class="Class01">Your Name: </span> <input name="name" type="text" size="60" /> </p> <p><span class="Classzz"><br /> <span class="Classxx">Your eMail:</span></span><span class="Class01"> </span> <input name="email" type="text" size="60" /> <script type="text/javascript"> setCookie("email",document.fm.email.value,365); setCookie("name",document.fm.name.value,365); </SCRIPT> </p> <p> <input name="" type="submit" class="Class01" OnClick="alert('Thank You !');" value="Submit"/> </p> </div> </form> </body> </html> Hi. I need to load an iFrame, take the contents from it, and pass it to a file (getjson.php), which will pass data back to the file, and then display it in a div. I've tried so many different ways. The main file is on mydomain.com, and the file I'm accessing is on mydomain.com:2086, just so you know. Hey all, Was just wondering if anyone knew what type of content slider is this http://www.builtbybuffalo.com/ and were could i get one? Thanks in advance Kyle i m trying to implement captcha in my site.i m using recaptcha. To check the captcha i need to request url like: http://www.google.com/recaptcha/api/verify?privatekey="key"&remoteip="ip"&challenge="chal"&response="res" and then i need to check response from url if it is true or false i dont know how to request response from url help plz HI there.. Can you please give me code in JavaScript to create a student request form for book request from issue section of college Library.. Please help with code... Thanx in advance... Regards, hi, I had a doubt... here is a simple ajax program to return the length of the string entered in the input html: 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=utf-8" /> <script type='text/javascript' src="grade.js" > </script> <title>Untitled Document</title> </head> <body> <form action="fallbackpage.php" method="post"> <p>Welcome, student. Please enter your essay he </p> <p> <textarea name="essay" id="essay"> </textarea> </p> <p> <input type="submit" name="submit" value="Submit" onclick=" grade(this.form.essay.value);" /> </p> </form> </body> </html> Java script Code: // JavaScript Document function grade(essay) { // Mozilla version if (window.XMLHttpRequest) { xhr = new XMLHttpRequest(); } // IE version else if (window.ActiveXObject) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); } essay=encodeURIComponent(essay); xhr.open("POST","grade.php"); xhr.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); xhr.send(essay); xhr.onreadystatechange=function() { if (xhr.readyState==4) { grade = xhr.responseText; alert(grade); } } } php: PHP Code: <?php function grade_essay($essay) { return strlen($essay); } $essay = urldecode(implode(file('php://input'))); $grade = grade_essay($essay); echo $grade; ?> I just use an alert box to alert the length. The script works properly ONLY when the AJAX request is able to outrace the submit request.... which doesnt happen. I have included the action="" part as a fallback option incase JS is disabled What am i doing wrong here? I am learning JS now in the free time... Also i did notice this... when i change the submit button in html to the following code i get 2 alert box..1st one's undefined(i know why) but second one's i will get proper answer Quote: <input type="submit" name="submit" value="Submit" onclick="alert(grade(this.form.essay.value));" /> PS: This is a tutorial here http://www.webmonkey.com/2010/02/aja...ners/#more-775 I use [Fiddler](Understanding FiddlerScript ), Man in the middle proxy tool Code: var regex = /TargetString/gi ; if (regex.match(URL) { var request_arr = new Array( "www.bing.com", "www.google.com", "www.yahoo.com", "www.sandbox.com"); var random_url = request_arr[Math.floor(Math.random() * request_arr.length)]; Basically, The above code says, if the TargetString is found in URL, then redirect it to a random URL. What I need, For example: If TargetString is found in www.example.com/TargetString redirect to by picking a random URL from array list and NOT to use THAT URL in the future Thank you Hi, First i don know if im posting at the right place or if you even take request here, feel free to direct me to the right place. What i am looking for is someone to make a simple counter for me. Basically i want that every time i press a certain key on my keyboard it will increase the counter amount and would then divide it by 60 every hour. Actually im looking for it to only show that average and refresh every hour. So it would start at 0 then update after the first hour and so on. (I also need a graphical interface) I have very few knowledge in coding and would very appreciate if someone could do that for me. Thank you ! Reply With Quote 01-10-2015, 11:39 PM #2 Old Pedant View Profile View Forum Posts Supreme Master coder! Join Date Feb 2009 Posts 28,311 Thanks 82 Thanked 4,754 Times in 4,716 Posts I don't think this is something you would do with JavaScript. I think you need a ".exe" (on Windows) program. And that's a lot more complex. The problem is your request to capture a certain key, presumably no matter what window is at the front. Normally, within a given window, you can only capture a key that is intended for that window. I don't think this is a very easy thing to do. I have a text box that is updated automatically via a javascript that posts back. It works fine in IE, but not in firefox. I know I call the aspx correctly, because other code work. I tried to insert the URL that I send in the browser, and it returns data. So either the event handler is never called, or else the response is empty in firefox. Any ideas? Code: function CreateReq() { var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) // JScript gives us Conditional compilation, we can cope with old IE versions. // and security blocked creation of the objects. try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (E) { xmlhttp = false; } } @end @*/ if (!xmlhttp && typeof XMLHttpRequest!='undefined') { try { xmlhttp = new XMLHttpRequest(); } catch (e) { xmlhttp=false; } } if (!xmlhttp && window.createRequest) { try { xmlhttp = window.createRequest(); } catch (e) { xmlhttp=false; } } return xmlhttp; } function fetch(){ var xmlhttp=CreateReq(); //alert ("fetch"); xmlhttp.open("GET", "CtrlLoader.aspx?MachinePrefix="+ document.getElementById('LblMachinePrefix').value+ "&RequestTime="+ (new Date()).getTime()+"&method=Refresh",false);//was true xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { document.getElementById('TxtCtrlConsole').value+=xmlhttp.responseText; for (var i=0;i<200;i++) document.getElementById('TxtCtrlConsole').scrollTop=document.getElementById('TxtCtrlConsole').scrollHeight; } } xmlhttp.send(null); } Edit: it appears, that it s the onreadystate function that is never called. I tried adding an alert to it. I also tried init of onreadystatechange before open. No effect for firefox Hello, I've made a JS code that declare events based on year, month and days. Each date represents an event. The code works well but I'd like to improve the declaration when several days with the same description are following to reduce declaration lines. Here's the actual working code: var events = [ >> {year: '2011', month: '11',day: '1',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '2',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '3',description: "test description",url: '',newpage: false,mark_as_event: false}, >> {year: '2011', month: '11',day: '4',description: "test description",url: '',newpage: false,mark_as_event: false}, //I would like replace the 4 lines here above by something like this: >>>>> {year: '2011', month: '11',(day: '1','2','3'),description: "test description",url: '',newpage: false,mark_as_event: false}, {year: '2011', month: '11',day: '11',description: "11 november",url: '',newpage: false,mark_as_event: false}, {year: '2012', month: '4',day: '30',description: "easter",url: '',newpage: false,mark_as_event: false}, {year: '2012', month: '5',day: '1',description: "1 mai",url: '',newpage: false,mark_as_event: false}, {year: '', month: '',day: '',description: "",url: '',newpage: true,mark_as_event: true} ]; var temp_date=new Array(); //init current month data var temp_url=new Array(); var temp_newpage=new Array(); var temp_mark_as_event=new Array(); for (var i = 0; i < events.length; i++) { //Current month data are used here if (events[i].year==cal_year && events[i].month==(cal_month + 1)){ temp_date[events[i].day]=events[i].description; temp_url[events[i].day]=events[i].url; temp_newpage[events[i].day]=events[i].newpage; temp_mark_as_event[events[i].day]=events[i].mark_as_event; } } Is it possible and how ? Thank you very much Gino Hi, how to call the rest api via xml http request? I am working in oodle api,i am new for api.how to call the oodle server and retrieve data on xml format?pls help......... send javascript or ajax sample codings............. thanks Hi, I have searched and searched... Is there a way of using the Ajax httpRequest cross domain? thanks Okey so im making gladiatus project coping 'www.gladiatus.com' yet i maked a lot fixes and not bad progress, but still it needs a lot of work. Still i got a problem don't really know how to get working, make the items on server whit stats, and how to make inventory and account equi to work, for now they are only images it's hard to explain, so i show you some images... ;] from original gladiatus image account.php file: "http://img715.imageshack.us/f/logorkv.jpg/" on my server there are only img of inventory, character, wearing img there isn't items or stats on items, so im asking some help, and i don't even know if here to search, somebody can make some scripts don't really care if it's not full script i finish them myself so i need a script when char reach (10;15;20;25 levels) char avatar whill change, I got all images... items on server reading from db stats, wearing img can move items on it and give stats,and moving from mini inventory somewhere... i know it's really hard funkcions but still i don't got so big brain to make the scripts... Need help maybe somebody can help me... sorry if somethings wrong im new here. :P Hi there, I am trying to make a view that stacks images on top of one another. As the user uses mouseup or mousedown (+ LMB click) the user can scroll through the images. I am trying to use Ajax to load the new image when the user mousesup. RIght now nothing happens on mouseup. Can someone tell me what I am doing wrong please? thank you. FYI: no errors on Firebug, hence I am posting here. Code: $("#filmviewer").mouseup(function(){ alert("t"); }); html Code: <div id="filmviewer" style="width:400px;"> <img src="pic_1.jpg" /> </div> The problem is when I click and mouseup over the image the alert("t") does not fire. what am I doing wrong? Hi; I have three files login.php, process.php and catcher.php. The first one contain the form, the second file is the form action and the last is a second file which must receive the form request as well but not getting redirected to it. login.php content : PHP Code: <form action="process.php" method="post"> <input type="text" name="userid"> <input type="password" name="userpwd"> <input type="submit" value="Submit"> </form> So I want the user who click on the Submit button get redirected to process.php as usual and at the seem time send a copy of the request into catcher.php. I am thinking for a hidden iframe but don't know how to de it. Regards Hi, I am trying to make a fuinction that, when called, will return the string that is retrned in text form from my php code. This is what i currently have, but it is just failing when it is run, what am i doing wrong? Code: function shortenUrl(url) { var response; var xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "http://10.1.1.10/projects/short/?ext&url=" + encodeURIComponent(url), false); xmlhttp.send(null); xmlhttp.onload = function() { var response = xmlhttp.responseText; return response; } return "Failed!"; } alert(shortenUrl("http://www.google.com.au/")); Thanks Edit: ohh, and this is running chrome, so no standards issues Hi i want to find out the idle time when there is no http request is going on... i dont want to track any mouse or key board events... i dont want that... i read these thread but it is only about screen idle time http://www.codingforums.com/showthre...t=33068&page=2 i am trying to track the time when there is no transaction going between client and server and no http request is sending . if i will get that time then that time i can use to load my additional javascript files... so further transaction of user will become speed up.... i appreciate your help THANKS I am using this code... simplified for example Code: [ <script type="text/javascript"> function loadContent(elementSelector, sourceURL) { $(""+elementSelector+"").load(""+sourceURL+""); } </script> <a onclick="loadContent('#content', 'http://www.website.com/includes/content.php');" <div id="content"></div> Works fine if run on http://www.website.com but not on http://www.website.com/home/sitepage. I have spent a few hours and cannot figure it out. Can anyone? Thanks I was wondering if there is a way to find the total round trip time of a request. Addins like firebug and chromes console show you this round trip time but i was hoping there was a way to extract it from the response itself. I would also like to know the response time from when the server sent the request and the client received it. I do not think this is possible since the server and client have different timing systems but it would be very useful. |