JavaScript - Click Hyperlink From Function
I need to simulate a mouseclick on a hyperlink with a function.
Any idea if this is possible ? Similar TutorialsHello I'm a beginner when it comes to javascript. I found a nice script that did what I wanted, which was have 3 "buttons" that on hover change a different image to the side of them. However, I also would like the button that if clicked to go to a section of the website - so an internal link. I was slightly confused when reading that to have a link in javascript isn't good practice. How could I achieve this? I would really appreciate any help, thank you below is the code Code: <script language="JavaScript" type="text/JavaScript"> <!-- function MM_preloadImages() { //v3.0 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array(); var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}} } function MM_swapImgRestore() { //v3.0 var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; } function MM_findObj(n, d) { //v4.01 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; } function MM_swapImage() { //v3.0 var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];} } //--> </script> </head> <body bgcolor="FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="MM_preloadImages('information-white-alt.png','training-quote.png','training-white-alt.png','consultancy-quote.png','information-white-alt.png','information-quote.png')"> <table width="350" border="0" cellspacing="0" cellpadding="0"> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('b1up','','information-white-alt.png','biganchor','','information-quote.png',1)" onMouseOut="MM_swapImgRestore()"><img src="information-white.png" name="b1up" width="270" height="74" border="0" id="b1up"></a></td> <td rowspan="3"><div align="center"><img src="home-statement.png" name="biganchor" width="500" height="222" id="biganchor"></div></td> </tr> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('biganchor','','training-quote.png','b2up','','training-white-alt.png',1)" onMouseOut="MM_swapImgRestore()"><img src="training-white.png" name="b2up" width="270" height="74" border="0" id="b2up"></a></td> </tr> <tr> <td><a href="javascript:;" onMouseOver="MM_swapImage('biganchor','','consultancy-quote.png','b3up','','information-white-alt.png',1)" onMouseOut="MM_swapImgRestore()"><img src="information-white.png" name="b3up" width="270" height="74" border="0" id="b3up"></a></td> </tr> </table> I am trying to create a function that clicks a button within an iframe. I hope this is all that is needed.... i figured something like this but i know i’m wrong cause it doesn’t work. function close_it(){ var s = document.getElementById(“messagesBox”); var go = s.getElementByClassName(“box_title”); go.click(); return false; } Here’s the Dom Tree. <div class="messagesBox" id="messagesBox" style=""> <div style="" class="birdie clearfix"> //The 401 is differant everytime. <div class="box_blue"> <div class="box_top "> <a href="#" onclick="message.callNextInContainer($(this));return false" class="box_title" style"">X</a> Any help would be much appreciated. Hi, hope someone can help. doing some work with google maps api. I have a function called codeaddress, this is triggered by a search button. is there a way to add js to make an automatic click on results after search ? here is code of function.. Code: function codeAddress() { var address = document.getElementById("address").value; geocoder.geocode( { 'address': address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { map.setCenter(results[0].geometry.location); map.setZoom(10); } else { alert("City was not found: " + status); } }); } Hi guys I kinda needed help on jQuery/ javascript.. Here's the test page.. http://development.andrewfopalan.com/devpage/test.html# what I'm trying to do is like this.. http://trailers.apple.com/trailers/s...bandofmisfits/ the movie box... so far, I have made the cosmetics.. but the thing I was going to ask was.. when you click on the down arrow.. a popup dropdown list is going to show.. the problem is I am copying the same effect as the one with apple.. when you click outside of the popup dropdown list, the dropdown list should be fading out... but it wouldnt... I tried using doing.. it like this Code: $("#wrap" ).click(function () { $(".dropdown").fadeOut(); }); but the problem is.. whenever I click the down arrow button.. it continues to fadeout.. as soon as it fadesin... how should I do this? please guide me.. everything works just fine.. just this one.. I am really lost.. i the whole jquery code is in the page sirs... please help me pretty new to javascript/jquery.. How can I do this? I'm new to JavaScript. I tried messing with While but it just caused lag as it kept looping infinitely. The problem I think is that I have a variable that changes every time I click the button. The function changes the variable. So it successfully changes the variable once to my likings, then when I click the button (thus running the function) it does nothing. Here's an example I created to show you Quote: <html> <head> <script type="text/javascript"> var x = 50; var y = Math.floor(Math.random()*5); function test() { var a = x+y document.getElementById("testing").innerHTML=a; } </head> <body> <p id="testing"></p> <input type="button" value="asdf" onclick="test()" /> </body> </html> So in this case, I need to click the button multiple times in which each time it should add y to x. It only works once and then goes kaput. Thanks! Hi, I have a DOM click event that creates a <span>. When the user clicks a button, it turns that <span> into a textarea that the user can type a new name in, press enter, and then the span contains the text the user input. Sort of like when you rename a file in Windows Explorer. Anyway, the code is something like this, and I'm wondering if I can use 'area_el' in this way... right now it's giving me the error that area_el is undefined, even though I define it in the function that contains the Event declaration. The first part is the Dom stuff to make it all work. It's not stuff I need to mess with, but I'm putting it here in case it's useful. Code: var Dom = { get: function(el) { if (typeof el === 'string') return document.getElementById(el); else return el; }, add: function(el, dest) { var el = this.get(el); var dest = this.get(dest); dest.appendChild(el); }, remove: function(el) { var el = this.get(el); if(el.parentNode != null) el.parentNode.removeChild(el); } }; var Event = { add: function() { if (window.addEventListener) { return function(el, type, fn) { Dom.get(el).addEventListener(type, fn, false); }; } else if (window.attachEvent) { return function(el, type, fn) { var f = function() { fn.call(Dom.get(el), window.event); }; Dom.get(el).attachEvent('on' + type, f); }; } }() }; The following code defines what happens when the user clicks submit to create a polygon. I also have some variables: Code: var created_area_array = Array(); var createdarea_index = 0; var number_of_areas_saved=0; var currently_renaming=false; Event.add(window, 'load', function() { Event.add('SubmitArea', 'click', function() { if(polyPoints.length>0) add_created_area(); }); }); Finally, where the issue is. I define area_el in the function below, and further down I want to pass it to a function within the "rename" click event, but I get an error that area_el is undefined. Code: function add_created_area() { number_of_areas_saved++; var area_el = document.createElement('span'); var area_el_remove = document.createElement('span'); var area_el_rename = document.createElement('span'); var new_entry = polyPoints; var new_entry_array_index = "Area" + (createdarea_index); var new_entry_array_name = "Area #" + (createdarea_index+1); area_el.innerHTML = '<span class=\"address-text\">' + new_entry_array_name + '</span><br>'; area_el_remove.innerHTML = "<a onMouseOver=\"rollover('address_remove')\" onMouseOut=\"rollout('address_remove')\" style='cursor:pointer;'>" + "<img src=\"images/tabs-icons/normal-address_remove.png\" name='address_remove' title='remove' alt='remove'></a> "; area_el_rename.innerHTML = "<a onMouseOver=\"rollover('area_rename')\" onMouseOut=\"rollout('area_rename')\" style='cursor:pointer;'>" + "<img src=\"images/tabs-icons/normal-area_rename.png\" name='area_rename' title='rename' alt='rename'></a> "; created_area_array[new_entry_array_index] = new_entry; createdarea_index++; Dom.add(area_el_remove, 'CreatedAreas'); Dom.add(area_el_rename, 'CreatedAreas'); Dom.add(area_el, 'CreatedAreas'); Event.add(area_el, 'click', function(e) { if(!currently_renaming) { polyPoints = []; var thePolyPoints = (created_area_array[new_entry_array_index]).toString(); alert(thePolyPoints); //formatting created_area_array[new_entry_array_index] to store as polygon points in the polyPoints array thePolyPoints = thePolyPoints.replace(/[\[\]{}]/g, ""); thePolyPoints = thePolyPoints.replace(/Location/g, ""); //adding the co-ordinates to the polyPoints array thePolyPoints = thePolyPoints.split(","); for(var ctr=0; ctr+1<thePolyPoints.length; ctr+=2) { var location1 = new Microsoft.Maps.Location(thePolyPoints[ctr],thePolyPoints[ctr+1]); polyPoints.push(location1); } var out=""; for(var i=0; i<polyPoints.length; i++) { out += polyPoints[i] + " "; } alert(out); //creating the polygon and searching... if(create_area==true) { drawPolygon(); polygonSearch(); } else if(create_area==false) { document.getElementById('createarea').innerHTML = "<a id='createarea'><span class='create_area' style='color:blue'><strong>Create Area</strong></span></a>"; document.getElementById("mapDiv").oncontextmenu = function(){return false} MouseUpHandlerId = Microsoft.Maps.Events.addHandler(map, "mouseup",MouseUpHandler); MouseDownHandlerId = Microsoft.Maps.Events.addHandler(map, "mousedown",MouseDownHandler); MouseMoveHandlerId = Microsoft.Maps.Events.addHandler(map, "mousemove",MouseMoveHandler); MouseOverHandlerId = Microsoft.Maps.Events.addHandler(map, "mouseover",MouseOverHandler); drawPolygon(); polygonSearch(); create_area=true; } } }); Event.add(area_el_remove, 'click', function(e) { Dom.remove(this); Dom.remove(area_el_rename); Dom.remove(area_el); if(number_of_areas_saved>1) number_of_areas_saved--; }); Event.add(area_el_rename, 'click', function(e) { if(!currently_renaming) { area_el.innerHTML = '<textarea name=\"renaming_area\" id=\"renaming_area\" style=\"width:200px;height:10px;background-color:#DCDCDC; resize:none;font-size:8px;\" onKeyPress=\"return enter_rename(area_el, event)\" maxlength=\"30\"></textarea><br>'; currently_renaming=true; } }); Event.add("createdarea_clear", 'click', function(e) { Dom.remove(area_el_remove); Dom.remove(area_el_rename); Dom.remove(area_el); created_area_array = []; number_of_areas_saved=0; createdarea_index=0; }); } The enter_rename(area_el, event) function that isn't passing in my variable. Code: function enter_rename(area_el, event) { var keyPressed = (event.which) ? event.which : event.keyCode; var current_str = document.getElementById("renaming_area").value; if(keyPressed == 13) { if(current_str.length>0) { if(allSpaces(current_str)==true) { alert("Please enter a meaningful area name."); return false; } else { area_el.innerHTML = '<span class=\"address-text\">' + current_str + '</span><br>'; currently_renaming=false; return true; } } else return false; } else return true; } Making area_el global does not clear the span elements when I click my "createdarea_clear" button, however when it's local, the function works as expected. Hi guys I kinda needed help on jQuery/ javascript.. Here's the test page.. http://development.andrewfopalan.com/devpage/test.html# what I'm trying to do is like this.. http://trailers.apple.com/trailers/s...bandofmisfits/ the movie box... so far, I have made the cosmetics.. but the thing I was going to ask was.. when you click on the down arrow.. a popup dropdown list is going to show.. the problem is I am copying the same effect as the one with apple.. when you click outside of the popup dropdown list, the dropdown list should be fading out... but it wouldnt... I tried using doing.. it like this Code: $("#wrap" ).click(function () { $(".dropdown").fadeOut(); }); but the problem is.. whenever I click the down arrow button.. it continues to fadeout.. as soon as it fadesin... how should I do this? please guide me.. everything works just fine.. just this one.. I am really lost.. i the whole jquery code is in the page sirs... please help me pretty new to javascript/jquery.. I have a question: look at the following html code: /****html***/ <div class='class1'>text1</div> <div class='class1'>text2</div> <div class='class1'>text3</div> ...... /**html***/ If I want to change the background color of the textn by clicking it, what should I do instead of inserting "onclick='someFunction()'" in every div? Greetings, I'm looking to add keycode Accessibility to an html + javascript interaction. It's basically like tic tac toe where a user clicks on a cell (these cells are created by divs) and an 'O' appears in the cell. I'd like to be able to tab through the cell fields and hit the spacebar to put the 'O' in the focused cell. Here's an example of the html divs... [code] <div class="grid"> <div class="row row-1"> <div class="box true"><div class="inner" tabindex="0" id="orange"></div></div> <div class="box true"><div class="inner" tabindex="0" id="orange"></div></div> <div class="box true"><div class="inner" tabindex="0" id="orange"></div></div> <div class="box"><div class="inner" tabindex="0" id="orange"></div></div> <div class="clear"></div> </div> </div> [code] What I'm needing to know is where/what code goes into the .js to set up a keydown event. Here's the .js being used... [code] $(document).ready(function() { // init $('#holder .section:first').addClass('current-slide'); $('#nav .btn:first').addClass('current-slide'); $('#holder .section').addClass('noanswer'); $('#holder .section').delay(300).animate({'top':'0px'},{duration:600,easing:'easeOutCirc'}); //how fast the screen comes down // end init $('.noanswer .box').hover(function() { if ($(this).hasClass('selected')) { $(this).addClass('box-highlight-hover'); } else { $(this).addClass('box-highlight'); } }, function() { if ($(this).hasClass('selected')) { $(this).removeClass('box-highlight-hover'); } else { $(this).removeClass('box-highlight'); } }); // box functions $('.noanswer .box').live('click',function() { $(this).addClass('selected'); }); $('.noanswer .selected').live('click',function() { $(this).removeClass('selected'); $(this).removeClass('box-highlight-hover'); }); // slide animations $('#nav .mobility-btn').click(function() { if ($('.section').is(':animated')) { } else { $('#nav .btn').removeClass('current-slide'); $(this).addClass('current-slide'); $('.section').css({'z-index':'5'}); $('#mobility').css({'top':'-350px','z-index':'10'}); $('#mobility').animate({'top':'0px','z-index':'10'},{duration:600,easing:'easeOutCirc'}); //how fast the screen comes down $('.section').removeClass('current-slide'); $('#mobility').addClass('current-slide'); } }); $('#nav .vision-btn').click(function() { if ($('.section').is(':animated')) { } else { $('#nav .btn').removeClass('current-slide'); $(this).addClass('current-slide'); $('.section').css({'z-index':'5'}); $('#vision').css({'top':'-350px','z-index':'10'}); $('#vision').animate({'top':'0px','z-index':'10'},{duration:600,easing:'easeOutCirc'}); //how fast the screen comes down $('.section').removeClass('current-slide'); $('#vision').addClass('current-slide'); } }); $('#nav .hearing-btn').click(function() { if ($('.section').is(':animated')) { } else { $('#nav .btn').removeClass('current-slide'); $(this).addClass('current-slide'); $('.section').css({'z-index':'5'}); $('#hearing').css({'top':'-350px','z-index':'10'}); $('#hearing').animate({'top':'0px','z-index':'10'},{duration:600,easing:'easeOutCirc'}); //how fast the screen comes down $('.section').removeClass('current-slide'); $('#hearing').addClass('current-slide'); } }); $('#nav .cognitive-btn').click(function() { if ($('.section').is(':animated')) { } else { $('#nav .btn').removeClass('current-slide'); $(this).addClass('current-slide'); $('.section').css({'z-index':'5'}); $('#cognitive').css({'top':'-350px','z-index':'10'}); $('#cognitive').animate({'top':'0px','z-index':'10'},{duration:600,easing:'easeOutCirc'}); //how fast the screen comes down $('.section').removeClass('current-slide'); $('#cognitive').addClass('current-slide'); } }); // result $('.answerSubmit').hover(function() { $(this).addClass('answerSubmitHover'); }, function() { $(this).removeClass('answerSubmitHover'); }); $('.answerSubmit').live('click',function() { var parent = $(this).parents('.section'); var scoreParent = $(this).parent('.result'); // Calculate max score var maxScore = parent.find('.box').length; // Calculate actual score var actualScore; var selectednotTrue = 0; var selectedCorrect = 0; var notTrue = 0; actualScore = parent.find('.box').length; selectedCorrect = parent.find('.box.selected.true').length; notTrue = parent.find('.box:not(.true)').length; selectednotTrue = parent.find('.box.selected:not(.true)').length; actualScore = notTrue - selectednotTrue + selectedCorrect; scoreParent.find('.answer').html(actualScore); scoreParent.find('.outOf').html(maxScore); $(this).hide(); parent.find('.score').show(); parent.addClass('answer').removeClass('noanswer'); }); }); [code] Please let me know if I'm unclear or if more code is necessary. Thanks for any help you can give! k Hi all, Background: I'm currently working on a landing page which will display the same on both desktop & mobile devices, which is what we "want" for now. However, we've created an alternate registration page for mobile devices. This page can be accessed by clicking on a specific button, which has a class on it that will determine if the user is on a mobile device or not. If they are not, the normal action will occur, such as a registration popup, built specifically for desktop users. The problem is: I'm firstly having to use .remove to take away the class of pbx_ajax which operates the popup, so mobile users aren't affected by the popup and will continue onto the page we specially built for them. However, it seems my script is removing the class straight away, which prevents the popup from working for desktop users. Secondly, the script doesn't actually seem to work, it simply doesn't fire, which begs the question if i've cocked up my class bind. Code is attached below, please if anyone has any advice, do let me know as i'm at my wits end. Oh and i'm sure you'll notice, i'm polling for when the jQuery has loaded, as the library is located at the bottom of our site (its a rather large site). The javascript/jquery Code: //$(document).ready(function() { //Global function that will detect what device the page is being viewed on function globalDetectDevice() { var deviceIphone = "iphone"; var deviceIpod = "ipod"; //Initialize our user agent string to lower case. var uagent = navigator.userAgent.toLowerCase(); //************************** // Detects if the current device is an iPhone or iPod Touch. function DetectDevice() { if (DetectIphone()) { window.location = "/landing/register/mobile" ; } else if (DetectIpod()) { window.location = "/landing/register/mobile" ; } else { return false; } } } //Binding the above function to a class, that we can then attach to any clickable element //As jQuery is at the bottom of page, we poll the function until jQuery has loaded, once loaded, we clear the polling using clearTimout var bindTimer = setInterval(function() { if ("undefined" != typeof jQuery && globalDetectDevice) { $('.detectDevice').removeClass('pbx_ajax').bind('click', DetectDevice); clearTimeout(bindTimer); } }, 50); //} the html button Code: <a class="detectDevice pbx_ajax" title="Join Free" href="?cat=popup&action=open&settings=pbx_popup_register">~graphic("btn-get-started-prints-LP")</a> thanks for any help Ok know those people who are in the bad habit of double clicking everything? Well my site breaks if they double click it... is there a script I can use that won't let my functions run more then once every so many seconds? to avoid double clicking errors? Hey guys just need a little help. I need to create a little script that clicks a link automatically and opens it up in a new page. So far I have this: Code: <head> <script> function autoClick(){ document.getElementById('linkToClick').click(); } </head> <body onload="setTimeout('autoClick();',3000);"> <a id="linkToClick" href="http://www.google.com" rel="nofollow" target="_blank">GOOGLE</a> </body> It works but the problem is that IE popup blocker keeps blocking the new window. Is there a way to do the same thing with javascript without it having blocked by IE popup blocker? hai.... this is my code: <a id="idname" onclick="show('idname')">34</a> in javascript function show(){ } Here how can i get that number 34? please Help me Thanks in advance a href tag is working finely.but the hyper-linked page is opening in the same tab..how to open it in different tab..please help me out..
I am creating calander control for the 1 year using javascript.the day in which click a table is pop up at absloute position . i want table is popup at relative position where selected date is click. Here is my code <script language="javascript" type="text/javascript"> var k=0; var month; var pagedata; var check=0; var tabledata = ''; var counter = 0; var editVal=0; var editRow=0; var selecteditemcode=""; var counter=0; function day_title(day_name) { mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode(String(day_name)); mycurrent_cell.appendChild(currenttext); } function makeArray(n) { this.length=n; for (var i = 1; i <= n; i++) this[i] = 0 return this } var flag=false; var index; var tempdata; var mybody ; var rowData = new Array(); var colData = new Array(); var mytable function fill_table(m_name,m_length,mm) { counter+=1; if(k==0) { alert(this_month); k=this_month; } else { alert(k); k +=1; if(k>12) { alert(k); alert(this_year); if(flag==false) { this_year+=1; flag=true; alert("IN "+k); alert("IN "+this_year); } } } mybody = document.getElementById('showtb'); mytable= document.createElement("table"); mytable.setAttribute("id",+String(m_name)+"_"+String(this_year)); mytablebody = document.createElement("tbody"); head_row = document.createElement("tr"); head_cell = document.createElement("td"); headtext = document.createTextNode(String(m_name)+"_"+String(this_year)); head_cell.appendChild(headtext); head_cell.setAttribute('colSpan','7'); head_row.appendChild(head_cell); head_cell.setAttribute('className','titlebar'); head_row.appendChild(head_cell); mytablebody.appendChild(head_row); mycurrent_row = document.createElement("tr"); counter+=1; mycurrent_row.setAttribute("id",String(counter)); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Sun"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Mon"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Tue"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Wed"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Thu"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Fri"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode("Sat"); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mytablebody.appendChild(mycurrent_row); day=1 if(m_name=="February" ) { if((this_year%4)==0) { m_length +=1; } } pagedata=''; var ddl; counter +=2; mycurrent_row = document.createElement("tr"); mycurrent_row.setAttribute("id",counter); for (var i=1;i<start_day;i++) { if(start_day<8) { mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode(" "); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); mycurrent_cell.setAttribute('className','promptbox'); mycurrent_row.appendChild(mycurrent_cell); } } var blnFlagFirstline=false; for (var i=start_day;i<8;i++) { blnFlagFirstline=true; alert("this_day "+ this_day+ " i "+ i); if(blgFlagButtons==false) { if(this_day <=day) { mycurrent_cell = document.createElement("td"); currenttext = document.createElement("a"); currenttext.setAttribute("href", "javascript:fnDivertedFlight();"); currenttext.setAttribute("onClick","this.blur();"); var txt = document.createTextNode(""+String(day)); currenttext.appendChild(txt); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); blgFlagButtons=true; } else { if(blgFlagButtons==false) { mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode(""+String(day)); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } else { mycurrent_cell = document.createElement("td"); currenttext = document.createElement("a"); currenttext.setAttribute("href", "javascript:fnDivertedFlight();"); currenttext.setAttribute("onClick","this.blur();"); var txt = document.createTextNode(""+String(day)); currenttext.appendChild(txt); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } } } else { mycurrent_cell = document.createElement("td"); currenttext = document.createElement("a"); currenttext.setAttribute("href", "javascript:fnDivertedFlight();"); currenttext.setAttribute("onClick","this.blur();"); var txt = document.createTextNode(""+String(day)); currenttext.appendChild(txt); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } day++; } if(blnFlagFirstline==true) { mytablebody.appendChild(mycurrent_row); } counter+=1; mycurrent_row = document.createElement("tr"); mycurrent_row.setAttribute("id",counter); while (day <= m_length) { for (var i=1;i<=7 && day<=m_length;i++) { if(blgFlagButtons==false) { if(this_day <=day) { mycurrent_cell = document.createElement("td"); currenttext = document.createElement("a"); currenttext.setAttribute("href", "javascript:fnDivertedFlight();"); currenttext.setAttribute("onClick","this.blur();"); var txt = document.createTextNode(""+String(day)); currenttext.appendChild(txt); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); blgFlagButtons=true; } else { mycurrent_cell = document.createElement("td"); currenttext = document.createTextNode(String(day)); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } } else { mycurrent_cell = document.createElement("td"); currenttext = document.createElement("a"); currenttext.setAttribute("href", "javascript:fnDivertedFlight();"); currenttext.setAttribute("onClick","this.blur();"); var txt = document.createTextNode(""+String(day)); currenttext.appendChild(txt); mycurrent_cell.appendChild(currenttext); mycurrent_row.appendChild(mycurrent_cell); } day++ } mytablebody.appendChild(mycurrent_row); counter+=1; mycurrent_row = document.createElement("tr"); mycurrent_row.setAttribute("id",counter); } mytable.appendChild(mytablebody); mybody.appendChild(mytable); mytable.setAttribute("border", "10"); //mytable.style.background="aliceblue"; mytable.style.fontFamily="Verdana"; //mytable.style.width="1000px"; mytable.setAttribute("className","promptbox"); mytable.style.fontSize="10pt"; start_day = i } var blgFlagButtons; function fnCalender() { blgFlagButtons=false; month=new makeArray(12) month[1]="January" month[2]="February" month[3]="March" month[4]="April" month[5]="May" month[6]="June" month[7]="July" month[8]="August" month[9]="September" month[10]="October" month[11]="November" month[12]="December" month_length = new makeArray(12) month_length[1]=31 month_length[2]=28 month_length[3]=31 month_length[4]=30 month_length[5]=31 month_length[6]=30 month_length[7]=31 month_length[8]=31 month_length[9]=30 month_length[10]=31 month_length[11]=30 month_length[12]=31 today = new Date() today= new Date("July 13, 2008");//'Wed Oct 29 00:00:00 UTC+530 2008' this_day = today.getDate() this_month = today.getMonth()+1 this_year = today.getYear() this_year = (this_year< 1000) ? this_year + 1900 : this_year; begin_date = new Date("July 01, "+this_year) if((this_year%4)==0) { start_day = begin_date.getDay()+1 } else { start_day = begin_date.getDay()+1 } var MhVal; if(this_day>1) { MhVal=this_month; for(var i=1; i<=13;i++) { mon[i]=month[MhVal]; monlen[i]=month_length[MhVal] MhVal +=1 if(MhVal==13) { MhVal=1; } } } else { MhVal=this_month; for(var i=1; i<=12;i++) { mon[i]=month[MhVal]; monlen[i]=month_length[MhVal] MhVal +=1 if(MhVal==13) { MhVal=1; } } } if (start_day == 1){ start_day = 8 } if(this_day>1) { for (var m = 1;m<=13;m++){ //alert('month[m] - '+mon[m]+' month_length[m] - '+monlen[m]+' m - ' +m); fill_table(mon[m],monlen[m],m) // tabledata += "id"+counter+"="+pagedata; } } else { for (var n = 1;n<=12;n++){ fill_table(mon[n],monlen[n],n) } } } </script> <script language="javascript" type="text/javascript"> function fnDivertedFlight() { prompt3('', 'Roster','Diverted Flight Detail </B>', 'fnDivertedValues'); } function prompt3(promptpicture, prompttitle, message, sendto) { var posx = 0; var posy = 0; var e = window.event; if(e!=null) { if (e.pageX || e.pageY) { posx = e.pageX; posy = e.pageY; } else if (e.clientX || e.clientY) { posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; } } else { posx = 100; posy = 100; } promptbox = document.createElement('div'); promptbox.setAttribute ('id' , 'prompt') document.getElementsByTagName('body')[0].appendChild(promptbox) promptbox = eval("document.getElementById('prompt').style") promptbox.position = 'absolute' promptbox.top = posy promptbox.left = posx promptbox.width = 430 promptbox.border = 'outset 1 #bbbbbb' //Here I am open popup Tabletable } function fnDivertedValues(value1,value2,value3,value4,value6,value7,value5) { alert(value1+" , "+ value2+" , "+value3+" , "+value4+" , "+value5); need to make "left click" act as "middle click" -------------------------------------------------------------------------------- I need to make "left click" act as "middle click" for a web site ....thank you in advance for any and all help... [CODE] <script language="javascript"> function Click(4) { if (event.button==0; 1; ) } document.onmousedown </script>> Hi, I am going to open a new window on my web page , and run one link (which is important for me to be run ), then close that window after some seconds, but I do not want this window be visible by users. This is the code I used, but when I add visible= none, the function does not work, and my link cannot be run. <button onclick="myFunction()">Click</button> <script type="text/javascript"> function myFunction() { var win = window.open("link", '1366002941508','width=x,height=y,left=xx,top=yy', visible=none); setTimeout(function () { win.close();}, ss); } </script> I really appreciate for your suggestion ) Hello everyone, Here's the scenario I wish to plan out. I have an index.htm page ready. I want to be able to put in javascript code into the HTML coding that will write the ip address of the actual server that is hosting the website into a hidden text box. Then I want to insert this ip address into a hyperlink in the original index.htm to link to another html page (this will be a SSL secure page instead i.e. https://<ip address>). Also vice versa. (With SSL index.htm page have code that writes ip into hidden text box then hyperlink to the original http index page) thanks. Hope you follow me I've been hammering at this for quite a while and it has me stumped. I have 4 variables that I am creating in the head section of my code. I am passing 2 parameters to my test page via the url and they are intended to be used to construct alternate url's for use by menu buttons. This my test url. My test link Here is a code snippet that creates the alternate url's. Code: <script type="text/javascript"> var videofile = swfobject.getQueryParamValue('id'); var af = swfobject.getQueryParamValue('af'); function enLink() { var enLink = "http://jim.playourvideo.net/lsatest.htm?id=" + videofile + "&af=" + af; alert(enLink); } function spLink() { var spLink = "http://jim.playourvideo.net/lsatest.htm?id=sp" + videofile + "&af=" + af; alert(spLink); } function grLink() { var grLink = "http://jim.playourvideo.net/lsatest.htm?id=gr" + videofile + "&af=" + af; alert(grLink); } function frLink() { var frLink = "http://jim.playourvideo.net/lsatest.htm?id=fr" + videofile + "&af=" + af; alert(frLink); } </script> I am trying to call the appropriate function by clicking on one of menu buttons. When I click any of the buttons I get an alert showing that my url is properly constructed. But the link never seems to fire and result in switching video files. I did also try it with onclick - same result. What should happen is the page should reload and play a different regionally captioned file. For testing I haven't captioned the test files. Just trying to get the logic working. I'd sure appreciate some advice. Jonni I have a php page with a form and some hyperlinks. User types in the form's textarea, if the user forgets to click on submit button of the form and click on any hyper link, it should alert the user "The form has not been submitted" please submit form. if user clicks OK, the form will be submitted. How can I implement this?? onmouseclick works?? please help me.. thanks in adv |