JavaScript - Problem With Javascript Class Creating Popup
I've written a javascript class that displays a popup, but as soon as the code executes the popup vanishes.
I've stepped through the code, line by line and there's nothing that "hides" the popup, the DIV that is created by the class, just reverts back to the default configuration generated by the following function: Code: function generateMarkup() { //build markup var newNode = document.createElement( 'DIV' ); newNode.id = IDs.HelpPopup; newNode.style.visibility = 'hidden'; newNode.innerHTML = [ '<div id="popup">', '<div id="inside">', '</div>', '</div>' ].join( '' ); return newNode; } All the changes made to the DIVs via document.getElementById code is completely wiped out. For example: Code: document.getElementById("inside").innerHTML = sText; If I stop processing just before the Class returns to the form, the generated code is exactly as I expect it to be with all the dynamic modifications. The class is triggered by an onClick event on a BUTTON. I've tried to put a "sleep" function in after executing the function that modifies the DIVs, but that seems to execute before the function, not after, so the popup just flickers into existence and then vanishes. Can anyone give me any hint(s) as to how to stop this happening. Similar TutorialsHi, I have a code that opens a new window from a flash movie. The window opens fine, but the parent window goes blank and displays this on the top left of the screen: [object] (in IE8) [object Window] (in Firefox) Does anyone know what I'm missing? This is the code for the button that opens the new window: on (release) { getURL ("javascript:window.open('/RG_Map.pdf','RGCommunityMap','width=700,height=700');"); } 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"> <head> <title> Project 2 </title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <meta http-equiv="content-language" content="en-us" /> <link rel="stylesheet" href="../jsfiles/js_styles.css" type="text/css" /> <script type="text/javascript"> /* <![CDATA[ */ function checkForNumber(fieldValue) { var numberCheck = isNaN(fieldValue); if (numberCheck == true) { window.alert("You must enter a numeric value!"); return false; } return true; } function calculate() var shipping = 0; var total = 0; { if (document.forms[0].hand_tool.value != document.forms[0].hand_tool.value == true) (document.forms[0]item1.value == 20); { && document.forms[0].shipping.value == (shipping + 5); { && (document.forms[0].total.value = document.forms[0].hand_tool.value + document.forms[0].shipping.value) } } function confirmSubmit() { if (document.forms[0].first_name.value = "null") { window.alert("You have not entered the requested Customer Information."); return false; } else if (document.forms[0].last_name.value = "none" || document.forms[0].city.value = "" || document.forms[0].state.value = "none") { window.alert("You have not entered the requested Customer Information."); return false; } var pmntMethod = false for (var j=0; j<3; ++j) { if (document.forms[0].credit_card[j].checked == true) { pmntMethod = true; break; } } if (pmntMethod != true) { window.alert("You must select a method of payment."); return false; } return true; } function confirmReset() { var resetForm = window.confirm("Are you sure you want to reset the form?"); if (resetForm == true) return true; return false; } /* ]]> */ </script> </head> <body> <!-- Your XHTML here --> <h1>Purchase Order</h1> <form action="FormProcessor.html" method="get" enctype="application/x-www-form-urlencoded" onsubmit="return confirmSubmit();" onreset="return confirmReset();"> <h3>Products</h3> <table> <tr> <td> <p>Hand Tools <br />$20.00<img src="handtools.gif" alt="Hand Tools" class="img" /></p> </td> <td> <select name="hand_tool" size="1"> <option value="hand_tool">Hand Tool</option> <option value="saw">Saw</option> <option value="hammer">Hammer</option> <option value="screwdriver">Screwdriver</option> <option value="wrench">Wrench</option> <option value="pliers">Pliers</option> </select> </td> <td> <p>Power Tools <br />$30.00<img src="powertools.gif" alt="Power Tools" class="img" /></p> </td> <td> <select name="power_tool" size="1"> <option value="power_tool">Power Tool</option> <option value="circular_saw">Circular Saw</option> <option value="sabre_saw">Sabre Saw</option> <option value="drill">Drill</option> <option value="belt_sander">Belt Sander</option> <option value="table_saw">Table Saw</option> </select> </td> </tr> </table> <h3>Shipping Fees</h3> <table> <tr> <td>Item 1: <input type="text" name="item1" value="" onchange="calculate();" /></td> <td>Item 2: <input type="text" name="itme2" value="" onchange="calculate()" /></td> </tr> <tr> <td>Shipping: <input type="text" name="shipping" value="" /></td> <td>Total: <input type="text" name="total" value="" /></td> </tr> </table> <h3>Customer Information</h3> <p>First Name <input type="text" name="first_name" value="FirstName" onclick="document.forms[0].first_name.value = '';" onchange="confirmSubmit();"/> Last Name <input type="text" name="last_name" value="LastName" onclick="document.forms[0].last_name.value = '';" onchange="confirmSubmit();" /></p> <p>Street Address 1 <input type="text" name="address1" value="Address1" onclick="document.forms[0].address1.value = '';" onchange="confirmSubmit();" /></p> <p>City <input type="text" name="city" value="City" onclick="document.forms[0].city.value = '';" onchange="confirmSubmit();" /> State <input type="text" name="state" value="State" onclick="document.forms[0].state.value = '';" onchange="confirmSubmit();" /> Zip <input type="text" name="zip" value="Zip" onchange="return checkForNumber(this.value);" onclick="document.forms[0].zip.value = '';" /></p> <p>Phone <input type="text" name="phone" value="Phone" onchange="return checkForNumber(this.value);" onclick="document.forms[0].phone.value = '';" /> Fax <input type="text" name="fax" value="Fax" onclick="document.forms[0].fax.value = '';" onchange="return checkForNumber(this.value);" /></p> <p>Payment Method? <input type="radio" name="credit_card" />Visa <input type="radio" name="credit_card" />MasterCard <input type="radio" name="credit_card" />American Express</p> <p>Credit Card Number<input type="text" name="cardNumber" value="CardNumber" size="50" onclick="document.forms[0].cardNumber.value = '';" onchange="return checkForNumber(this.value);" /></p> <table> <tr> <td> <p>Expiration Month</p> </td> <td> <select name="month" size="1" style="width: 200px"> <option value="months">Month</option> <option value="january">January</option> <option value="february">February</option> <option value="march">March</option> <option value="april">April</option> <option value="may">May</option> <option value="june">June</option> <option value="july">July</option> <option value="august">August</option> <option value="september">September</option> <option value="october">October</option> <option value="november">November</option> <option value="december">December</option> </select> </td> <td> <p>Expiration Year</p> </td> <td> <select name="expiration" size="1"> <option value="2009">2009</option> <option value="2010">2010</option> <option value="2011">2011</option> <option value="2012">2012</option> <option value="2013">2013</option> <option value="2014">2014</option> </select> </td> </tr> </table> <p><input type="image" alt="Graphical image of a submit button" src="submit.gif" onchange="confirmSubmit()" /></p> <p><input type="reset" value="Reset Purchase Order Form" onchange="confirmReset();" /></p> </form> <!-- your XHTML validation icon--> <p> <a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" style="border: 0px;" /></a> <a href="http://jigsaw.w3.org/css-validator/check/referer"> <img src="http://www.austincc.edu/jscholl/images/vcss.png" alt="Valid CSS!" height="31" width="88" style="border: 0px;" /></a> </p> </body> </html> Hi, I have 'adapted' some code from another thread to create a popup window that will need to refresh with appropriate page contents, depending on the links that a user clicks on in the main window. My problem is that the code opens 2 windows instead of 1. I'm obviously misunderstanding or overlooking something. Can anyone please help. Code: Select Case x Case 0 Longname = "<a href='" & "pcso.htm" & "' onclick=" & chr(39) & "popup(this, " & chr(34) & "notes" & chr(34) & ")" & chr(39) & " target='" & "_blank" & "'>PCSO</a>" Case 1 Longname = "<a href='" & "call handler.htm" & "' onclick=" & chr(39) & "popup(this, " & chr(34) & "notes" & chr(34) & ")" & chr(39) & " target='" & "_blank" &"'>Call Handler</a>" Case 2 Longname = "<a href='" & "investigating officer.htm" & "' onclick=" & chr(39) & "popup(this, " & chr(34) & "notes" & chr(34) & ")" & chr(39) & " target='" & "_blank" & "'>Investigating Officer</a>" Case 3 Longname = "<a href='" & "detention officer.htm" & "' onclick=" & chr(39) & "popup(this, " & chr(34) & "notes" & chr(34) & ")" & chr(39) & " target='" & "_blank" & "'>Detention Officer</a>" End Select and Code: <SCRIPT TYPE="text/javascript"> <!-- function popup(mylink, windowname) { var href; if (typeof(mylink) == 'string') href=mylink; else href=mylink.href; mywin = window.open(href, windowname, 'width=400,height=400,toolbar=no,directories=no,status=no,menubar=no, scrollbars=yes,resizable=no'); mywin.focus() } //--> </SCRIPT> Is there a way to setup in the header that all links on a page with class="myclass" will default to a small popup window with X parameters and size? So I don't have to do an onclick on each <a href>??
If the value is negative it should be in red, otherwise it should be in green. It looks like JavaScript completely ignores the css class. Help please. Code: <html> <head> <title>Prva</title> <style type="text/css"> span.Pozitivno { color:green; font-weight:bold; } span.Negativno { color:red; font-weight:bold; } </style> <script type="text/javascript"> function vpisi_stevila() { var a; var b; //Vnos spremenljivk a=prompt("Vnesi stevilo a:") b=prompt("Vnesi stevilo b:") a=a*1 //S tem spremenimo string v int b=b*1 //Izpis stevil if(a<0) { document.write("A:<span class='Negativno'> " + a + " </span> <br />"); } else { document.write("A:<span class='Pozitivno'> " + a + " </span> <br />"); } if(b<0) { document.write("A:<span class='Negativno'> " + a + " </span> <br />"); } else { document.write("A:<span class='Pozitivno'> " + a + " </span> <br />"); } document.write("Vsota:", a+b, "<br />"); document.write("Razlika:", a-b, "<br />"); document.write("Mnozenje:", a*b, "<br />"); document.write("Deljenje:", a/b, "<br />"); document.write("Ostanek:", a%b, "<br />"); if(a>b) //Ce je A vecje od B { document.writeln("A je <b>večje </b> od b") } if(a<b) //Ce je B vecje od A { document.writeln("A je <b>manjse </b> od b") } if(a==b) //Ce sta enaka { document.writeln("A je <b>enako </b> b") } } </script> </head> <body onload="vpisi_stevila()"> </body> </html> hey when i open a popup window by javascript it is an usual window though some customizable like whether displaying menubar, displayed position and some other options. but i want to createpopup windows like facebook popup windows which is nice,thin and immovable. please give me an example (code) to create a nice popup window or any other help regarding this. Alright I have never really created a class before and I have to for a project. This is what I have so far and I will try to explain the requirements I am looking for thoroughly and what problems I am having. Code: <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <script language="javascript" type="text/javascript"> function clock () { //Object Constructor this.setT = function() { //Method Set Time //Properties this.currentTime = new Date ( ); this.currentHours = this.currentTime.getHours ( ); this.currentMinutes = this.currentTime.getMinutes ( ); this.currentSeconds = this.currentTime.getSeconds ( ); } clock.prototype.displayTime = function () { clock.setT } } </script> <body> <form name="form1"> <p> <input type="text" rows=7 cols=60 name="currentTime"> <br> <input type="button" value="Set Time" onClick="clock.displayTime();"> <br> <input type="button" value="Display Time" onClick="currentTime.value= completeTime;"> <br> <input type="reset" value="Reset"> </p> </form> </body> </html> The clock class contains: Three Properties: Hours Minutes, Seconds Two Methods setTime (which uses date class to get current time) Must be defined in the constructor displayTime (returns a string displaying current time) Must be defined as a prototype property of constructor The below is a very rough outline, and probably not correct. I've been reading up on objects for the last few hours and can't be very sure of anything yet. Code: function clock() { this.currentTime = new Date ( ); var currentHours = currentTime.getHours ( ); var currentMinutes = currentTime.getMinutes ( ); var currentSeconds = currentTime.getSeconds ( ); this.setTime = function() { } } clock.prototype.displayTime = function ( ) { } I guess my biggest problem now is the outline. Any help would be great hopefully once i get what goes where i can actually start writing the code. I already have the full code to write a basic clock just like this but it doesn't use classes or any of this. Hello, I am new with Javascript and running into this problem that I don't understand. I define a base class that only contains an array "elements", and a derived class that contains nothing more (for simplicity): Code: function baseClass() { this.elements = new Array; } function derivedClass() { } derivedClass.prototype = new baseClass; Then I create two instances of the derived class, and add two elements in each: Code: a = new derivedClass(); a.elements.push("A"); a.elements.push("B"); b = new derivedClass(); b.elements.push("C"); b.elements.push("D"); When I examine the contents of these arrays, I see that both a.elements and b.elements contain {"A","B","C","D"} ! I.e. as if the two arrays are in fact the same array! But these are two separate instances of the class, I expect two separate arrays. Note that if instead I use the base class: Code: a = new baseClass(); a.elements.push("A"); a.elements.push("B"); b = new baseClass(); b.elements.push("C"); b.elements.push("D"); then I get a.elements = {"A","B"} and b.elements = {"C","D"}, as I would expect. Could someone explain to me the problem with using the derived class? Thank you, Stephanos Ok, I'm not a javascript expert, but I'm using a Drupal module called Calendar which uses some javascript to popup links in a DIV instead of going to a new page. This appears to work by adding class="popup" to links on the calendar. I want to use the same functionality to link to calendar events from other areas on the site, not just on the calendar. It looks like the javascript file is loaded on every page of the site, but adding class="popup" only results in an empty DIV with a close button, without actually loading the content. Can anyone please help me solve this? A link to what I'm working on is he http://67.220.206.170/~jazzbone/?q=home. The upcoming events section is a block from the Calendar view (created by the Calendar module), however it does not do popups by default like the calendar page, so I've tried adding class="popup" to these links to make it work. You can see in the main body of the page is a test link with class="popup" as a test as well. I want them to behave like the popups on the event calendar page. I think this is the javascript file in question: http://67.220.206.170/~jazzbone/site...r/jcalendar.js I know this is a lot, and I'm a newbie here, but I appreciate any help, thanks. Hi, I have a small script that opens a small popup in which to populate a form. What I want to do is include a variable so that a particular PHP page opens. I include where I am at present: HTML page calling JS popup: <input type="text" name="DOCUMENTS" id="DOCUMENTS" onclick="makeSelection(this.form, 'DOCUMENTS');"> JS Code: targetElement = null; function makeSelection(myform, id) { if(!myform || !id) return; targetElement = myform.elements[id]; var handle = window.open("../file_upload.php?dir=CODE", "mywindow","menubar=0,resizable=0,width=400,height=250"); } What I want to be able to do is get it so that the bit of JS that has 'dir=CODE' has a variable called from the HTML page. Is this possible, and if so, could anyone please help me out? Regards, Neil I have a loop that originally printed out a day, in a table, that linked to a new page. Code: out.println("<th height=100><a href=eventPage.jsp?month="+(n+1)+"&day="+d+">" + d + "</a>"); This works fine but now I want to instead have it be a link a page thats a pop up. The code I have now is as follows Code: out.println("<th height=100><a href="eventPage.jsp?month="+(n+1)+"&day="+d"" onclick="popUp(this.href);return false"> + d + "</a>">); and Code: <script type="text/javascript"> function popUp(URL) { <!-- window.open(URL,'width=300,height=300'); //--> } </script> I can not seem to find where I am going wrong. Any help would be appreciated. folks., i need to popup image on image hover?the image should be placed just above mouse pointer? i tried to implement event.x,event.y.. but it is not positoning well in all browsers..?is css need to be used here or please give me javascript code... this is the code function Large(obj,id,e) { // this is div tag,inside div i am placing imagebutton.. var imgbox=document.getElementById("imgbox"); var imgbtn=document.getElementById('<%=ImageButton3.ClientID%>'); imgbox.style.visibility='visible'; imgbtn.src=obj; imgbox.style.left=event.x; imgbox.style.top= event.y; } thank you Hey Guys, I'm trying to make a popup. Let me rephrase, not the type of popup that we all have cursed upon! But the same concept. I have a "control panel" type web application that i have developed. It is all completely dynamic. Each application has its own index.php file. My problem is, one of my applications i need has to open in a new window since its an external site. My problem is the way i have it setup dynamically in php i MUST have that inital index.php file. So what i have tried is to put in that index file just some javascript that opens a new window. Of course both IE and FF's popup blocker kick in. I need to find away around this. Does anyone have any ideas? So far i'd tried a window.open.... also tried creating a link with a target and id and then using click(); to deploy it. And i even tried creating a fake form with a target and an id and submiting it with javascript. Everything gets blocked. Thanks in advance, Jamie Hello Everyone, First of all i'd like to thank you for this wonderful forum, you people have helped me.. Now, i'm back here because i have this problem...i have a website built with drupal, www.plus-demo.info/drupal If you see the second menu, when you hover there is a submenu which pops out...what i want for this popup menu is to display in a fixed position...it shouldn't get out of the borders of the website...there is the code which has to do with it... Please help me... function muchomenu_display() { if (hoverParent) { hoverParent.addClass('hovering'); hoverBin = hoverParent.find('.muchomenu-bin'); /* display position */ //hoverBin.css('top', 'auto'); /* display position end */ animateIn(hoverBin); } } function muchomenu_close(){ if (hoverParent) { oldParentIdx = $('.muchomenu-parent').index(hoverParent); } for ( var i=0 ; i < megaParents.length ; i++ ) { megaParents.eq(i).removeClass('hovering'); } animateOut(hoverBin); } function checkHorizontalPosition(item) { var parentOffset = item.parents('.muchomenu-parent').offset(); var screenWidth = $(document).width(); var itemPosition = item.position(); var padding = 30; var p = item.width() + itemPosition.left + parentOffset.left + padding; if (p > screenWidth) { var newOffset = screenWidth - p; item.css('left', newOffset + 'px'); } } Hello! I have a script that loads a popup window on any page of a website, in order to temporarily cover the page's content. This popup window is supposed to load on top of page's content, acting as a sort of page blocker. So the visitor can't see what's on the page until he clicks the popup. The problem i'm having right now is when i put this script on a page that has iframe content. The iframe loads on top of this popup and not underneath as it's supposed to be. Do you guys have any advise on what should i do to make this work properly when using iframes on a page? Here is the script: Code: var blocker_originalHtmlOverflow; var blocker_originalBodyOverflow; function blocker_addLoadEvent(func) { var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { oldonload(); func(); } } } blocker_addLoadEvent(blocker_init); function blocker_init() { if(blocker_getCookie('content_unlocked')=='1') return; blocker_originalHtmlOverflow = document.getElementsByTagName('body')[0].style.overflow; blocker_originalBodyOverflow = document.getElementsByTagName('html')[0].style.overflow; document.getElementsByTagName('body')[0].style.overflow = 'hidden'; document.getElementsByTagName('html')[0].style.overflow = 'hidden'; function pageScroll() { window.scroll(0,0); // scroll to 0 if(blocker_getCookie('content_unlocked')!='1'){ scrolldelay = setTimeout('pageScroll()',100); // scrolls every 1 second } } pageScroll(); var haze = document.createElement('div'); haze.id = 'blocker_haze'; haze.style.filter = 'alpha(opacity=50)'; haze.style.opacity = .5; haze.style.height = '2000'; haze.style.width = '2000%'; haze.style.backgroundColor = '#000'; haze.style.position = 'absolute'; haze.style.top = '0px'; haze.style.left = '0px'; haze.style.zIndex = 1000000; var centerPane = document.createElement('centerPane'); centerPane.id = 'blocker_centerPane'; centerPane.style.width = '500px'; centerPane.style.height = '361px'; centerPane.style.border = '5px solid #CCC'; centerPane.style.position = 'absolute'; centerPane.style.left = '50%'; centerPane.style.marginLeft = '-250px'; centerPane.style.top= '100px'; centerPane.style.backgroundColor = '#FFF'; centerPane.style.zIndex = 1000001; centerPane.style.backgroundImage = 'url(http://www.fasgasfga.com/sfasdfasdf.jpg)'; centerPane.style.backgroundRepeat = 'no-repeat'; centerPane.style.backgroundPosition = '20px 10px'; centerPane.style.padding = '20px'; var h1 = document.createElement('h1'); h1.style.color = '#000'; h1.style.textAlign = 'center'; h1.style.fontSize = '36px'; h1.style.margin = '0 0 10px 0'; h1.style.padding = '8px 0 0 15px'; h1.style.fontFamily = 'arial'; h1.style.lineHeight = '36px'; h1.innerHTML = blocker_headline; centerPane.appendChild(h1); var p1 = document.createElement('p'); p1.innerHTML = blocker_instructionalText; p1.style.textAlign = 'center'; p1.style.padding = '20px 0 20px 0'; p1.style.margin = '0'; p1.style.fontSize = '18px'; p1.style.lineHeight = '18px'; p1.style.color = '#000'; p1.style.fontFamily = 'arial'; centerPane.appendChild(p1); var ul = document.createElement('ul'); ul.style.textAlign = 'center'; ul.style.margin = '0 0 10px 0'; ul.style.padding = '0'; ul.style.listStyleType = 'none'; for(var i = 0;i<blocker_surveryLinks.length;i++){ var li = document.createElement('li'); var a = document.createElement('a'); a.style.display = 'block'; a.style.fontSize = '17px'; a.style.lineHeight = '380px'; a.style.color = 'Black'; a.style.fontFamily = 'arial'; a.style.textDecoration = 'underline'; a.target = '_blank'; a.href = blocker_surveryLinks[i].url; a.innerHTML = blocker_surveryLinks[i].text; a.onclick = function(){ window.setTimeout(unblockContent, 55000); } li.appendChild(a) ul.appendChild(li); } centerPane.appendChild(ul); var p2 = document.createElement('p'); p2.style.textAlign = 'center'; p2.innerHTML = blocker_footerText; p2.style.padding = '20px 0 0 0'; p2.style.margin = '0'; p2.style.color = '#F50E0E'; p2.style.fontFamily = 'arial'; p2.style.fontSize = '15px'; p2.style.lineHeight = '15px'; centerPane.appendChild(p2); document.getElementsByTagName('body')[0].appendChild(haze); document.getElementsByTagName('body')[0].appendChild(centerPane); } function unblockContent(){ document.getElementsByTagName('body')[0].style.overflow = blocker_originalBodyOverflow; document.getElementsByTagName('html')[0].style.overflow = blocker_originalHtmlOverflow; document.getElementById('blocker_haze').style.display = 'none'; document.getElementById('blocker_centerPane').style.display = 'none'; //blocker_setCookie("content_unlocked", 1, 365, '/', ''); Set_Cookie( 'content_unlocked', 1 , 365, '/', '', '' ); } function Set_Cookie( name, value, expires, path, domain, secure ) { // set time, it's in milliseconds var today = new Date(); today.setTime( today.getTime() ); /* if the expires variable is set, make the correct expires time, the current script below will set it for x number of days, to make it for hours, delete * 24, for minutes, delete * 60 * 24 */ if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; } var expires_date = new Date( today.getTime() + (expires) ); document.cookie = name + "=" +escape( value ) + ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + ( ( path ) ? ";path=" + path : "" ) + ( ( domain ) ? ";domain=" + domain : "" ) + ( ( secure ) ? ";secure" : "" ); } function blocker_setCookie(c_name,value,expiredays){ var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays); document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()); } function blocker_getCookie(c_name){ if (document.cookie.length>0){ c_start=document.cookie.indexOf(c_name + "="); if (c_start!=-1){ c_start=c_start + c_name.length+1; c_end=document.cookie.indexOf(";",c_start); if (c_end==-1) c_end=document.cookie.length; return unescape(document.cookie.substring(c_start,c_end)); } } return ""; } hello everybody, here I'm asking for help again. sorry for that in advance. anyhow, I have the following code: 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"> <head> <link type="text/css" media="screen" rel="stylesheet" href="colorbox.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> <script type="text/javascript" src="../colorbox/jquery.colorbox.js"></script> <script type="text/javascript"> $(document).ready(function(){ $(".example7").colorbox({width:"300px", height:"500px", iframe:true, open: true}); }); </script> </head> <body onload="example7();"> <a class='example7' href="tofes.html"></a> teststestestest </body> </html> I want the lightbox window open only once a day for every unique visitor on my website. I understand I should use some sort of cookie implented, but I dont really understand how to. Thanks in advance, daniel. Hey everyone, I have a javascript problem which I think can be resolved by adding a few lines of code. I will try to explain my situation: Code: <img title='gameplay0001' class='popuplink' src="img/visual/gameplay/visual-gameplay-10.png"/>\ <span class='popup'> <span>gameplay0001</span> <img src="img/visual/gameplay/visual-gameplay-10_large.png" /> <div class='clear'></div> <div class='popupclosebtn'>back</div> </span> this javascript I wrote, allows me to do this: 1) I click on the element with class .popuplink 2) The span with the class popup that contains a span whose text equals the title of popuplink (in this case gameplay0001) appears 3) when I click popupclosebtn the popup closes this is all done by the next javascript: Code: $('.popuplink').each(function() { $(this).click(function() { var source = $(this).attr('title'); var popupContent = $(".popup:contains('" + source + "')"); var popupContainer = $("#popcontainerbase"); popupContainer.html(''); popupContainer.html(popupContent.html()); $("#popcontainerbase").fadeIn(200, function() { $('.popupclosebtn').click(function() { var popupContainer = $("#popcontainerbase"); popupContainer.html(''); $('#popcontainerbase').fadeOut(200, function() { }); }); $(document).keyup(function(e) { if (e.keyCode == 27) { var popupContainer = $("#popcontainerbase"); popupContainer.html(''); $('#popcontainerbase').fadeOut(200, function() { }); } }); }); }); }); Oh by the way, I put all the .popup content in a div called #popupcontainer, so my content won't affect my relative container div. So, this works perfect, text and images can be placed in the span .popup; no proplems. Additionally, I also have a jwplayer in my website. This works fine as well. With one exception: When I try to put a jwplayer video into a .popup window, IE fails to put the video in there. it just ignores it. My video popup page: Code: <img title='trailer01' class='popuplink' src="img/visual/trailer01.png"/> <span class='popup'> <span>trailer01</span> <div id="trailer01"> </div> <div class='clear'></div> <div class='popupclosebtn'>back</div> </span> The javascript source on the bottom of the page: Code: jwplayer("trailer01").setup({ controlbar:"over", "controlbar.idlehide": false, controlbar:"bottom", autostart: true, flashplayer: "jwplayer/player.swf", skin: "jwplayer/skins/glow.zip", wmode: "transparent", file: "video/trailer01.mp4", width: 490, height: 340 }); so, that is my situation. This script will not work in internet explorer. Can anyone tell me how to fix this? thanx in forward Hi, I adjusted a javascript code which was a clickable popup to an autoloading popup. Basicly when someone visits the page I want the popup to appear. It's working fine but Firefox doesn't display the popup on page load, only when clicked. (newsletter signup) Im just starting out on JavaScript. Can anyone help? here's the code Code: $(document).ready(function() { // Here we will write a function when link click under class popup var rel = popuprel3; // Here we will describe a variable popupid which gets the // rel attribute from the clicked link var popupid = $(this).attr('rel'); // Now we need to popup the marked which belongs to the rel attribute // Suppose the rel attribute of click link is popuprel then here in below code // #popuprel will fadein $(popuprel3).fadeIn(); // append div with id fade into the bottom of body tag // and we allready styled it in our step 2 : CSS $('body').append('<div id="fade"></div>'); $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); // Now here we need to have our popup box in center of // webpage when its fadein. so we add 10px to height and width var popuptopmargin = ($(popuprel3).height() + 10) / 2; var popupleftmargin = ($(popuprel3).width() + 10) / 2; // Then using .css function style our popup box for center allignment $(popuprel3).css({ 'margin-top' : -popuptopmargin, 'margin-left' : -popupleftmargin }); // Now define one more function which is used to fadeout the // fade layer and popup window as soon as we click on fade layer $('#fade').click(function() { // Add markup ids of all custom popup box here $('#fade , #popuprel3').fadeOut() return false; });}); theres a div on index.php with an id called popuprel3 I currently have a popup window that works fine but while that window is up on top and I click on another link that opens another window the popup goes behind that window. How do I code to get the popup window to always stay on top no matter what window I open up with the code I have below: Code: <script language="javascript" type="text/javascript"> function test() { setTimeout("self.focus()",3000) } function open_new_window() { //new_window = open("","hoverwindow","width=300,height=200,left=10,top=10"); new_window = window.showModelessDialog("","hoverwindow","width=300,height=200,left=10,top=10"); new_window.focus(); // open new document new_window.document.open(); // Text of the new document // Replace your " with ' or \" or your document.write statements will fail new_window.document.write("<html><title>JavaScript New Window</title>"); new_window.document.write("<body onBlur = "test();" bgcolor=\"#FFFFFF\">"); new_window.document.write ("Week 1 Question".bold()); new_window.document.write("<table><tr><td>Is there a role of process owner in your organization? If not, how will you overcome this challenge? Why do you need process owners as a Lean Six Sigma Green Belt Project Leader?</td></tr></table>"); new_window.document.write("<br />"); new_window.document.write("</body></html>"); // close the document new_window.document.close(); } // This is the function that will close the // new window when the mouse is moved off the link function close_window() { new_window.close(); } </script> Dear friends, I am using a Javascript which perfectly worked in all relevant browsers, including IE6 and IE7. Its advantage has been to be able to specify the window-size + to decide, whether there should be scrollbars or the option to resize it. It is also fully standards-compliant. It opens a new popup window and is triggered via the rel="popup" or rel="popup nofollow" attributes in the specified external links, e.g.: Code: <a href="http://www.codingforums.com/" rel="popup">CodingForums</a> <a href="http://www.codingforums.com/" rel="popup nofollow">CodingForums</a> The code however does not do its job in IE8. It follows the link, but does so in the old window, not a new popup window, and thus recurs to standard behavior of links. Here is the Javascript-Code, included in the header: Code: var properties = { width: 900, height: 450, scrollbars: 'yes', resizable: 'yes' }; function popup(){ var link = this.getAttribute( 'href' ); var prop_str = ''; for( prop in properties ){ prop_str = prop_str + prop + '=' + properties[prop] + ','; } prop_str = prop_str.substr( 0, prop_str.length - 1 ); var newWindow = window.open( link, '_blank', prop_str ); if( newWindow ){ if( newWindow.focus ) newWindow.focus(); return false; } return true; } function setupPopups(){ var links = document.getElementsByTagName( 'a' ); for( var i=0; i<links.length; i++ ){ if( links[i].getAttribute( 'rel' ) && (links[i].getAttribute( 'rel' ) == 'popup' || links[i].getAttribute( 'rel' ) == 'popup nofollow')) links[i].onclick = popup; } } window.onload = function(){ setupPopups(); } Since I am not an expert, I would greatly appreciate help to make this efficent code workable in IE8. Thanks in advance! CodeMat |