JavaScript - Question On Creating Window Using "window.open" Method
Hi,
In my "main.js" file I need to create a new window with a button. If the button clicked a function in the "main.js" file is called. I tried the following, but new window does not see the function in the "main.js" file. function create_new_window() { my_window = window.open ("","mywindow1","status=1,width=350,height=150"); my_window.document.write('<H1>My Window ...</H1>'); my_window.document.write('<form><input type="button" value="Submit" onClick="submitData();"/></form>'); .... } function submitData() { ... } Similar TutorialsHello, recently I have been to many government websites where I have noticed that the programmer has used window.open() method in JavaScript to link to different pages instead of using <a> tags! I was just getting curious to know whether it is normal or has it been used due to security concerns(if any, I don't know)? Any comments? Hi everyone, I was hoping you could help me with a faily easy question. I was asked to edit some script and I figured out most of it, however I can't seem to be able to make the links in my java script menu open in new pages. Any help would be appreciated. Below is a copy of the script. It's a very long script, so I just sent a section of it. Pleasse scroll down to the bottom to see where the links are (ex. http://www.korg.com, etc) Thank you, Paul. <!-- function mmLoadMenus() { if (window.mm_menu_1107110519_0) return; window.mm_menu_1107110519_0 = new Menu("root",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107110519_0.addMenuItem("Parts Department","location='/e/support/accessories.html'"); mm_menu_1107110519_0.addMenuItem("Warranty Registration","location='/e/support/warranty.html'"); mm_menu_1107110519_0.addMenuItem("F.A.Qs","location='/e/support/faqs.html'"); mm_menu_1107110519_0.addMenuItem("Tutorials & Guides","location='/e/support/tutorials.html'"); mm_menu_1107110519_0.addMenuItem("Related Products","location='/e/support/related_products.html'"); mm_menu_1107110519_0.addMenuItem("Downloads","location='/e/support/downloads.html'"); mm_menu_1107110519_0.addMenuItem("Newsletter","location='/e/support/newsletter.html'"); mm_menu_1107110519_0.addMenuItem("Owner’s Manual","location='/e/support/manual_request.html'"); mm_menu_1107110519_0.addMenuItem("Korg Proview Request","location='/e/support/literature_request.html'"); mm_menu_1107110519_0.addMenuItem("Suggested Retail Prices","location='/e/products/pricelists.html'"); mm_menu_1107110519_0.hideOnMouseOut=true; mm_menu_1107110519_0.menuBorder=1; mm_menu_1107110519_0.menuLiteBgColor='#2a4960'; mm_menu_1107110519_0.menuBorderBgColor='#000000'; mm_menu_1107110519_0.bgColor='#000000'; window.mm_menu_1107105559_0_1 = new Menu("KORG",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0_1.addMenuItem("KORG.com","location='http://www.korg.com'"); mm_menu_1107105559_0_1.addMenuItem("Pricelist","location='http://www.korgcanada.com/e/products/pricelists.html'"); mm_menu_1107105559_0_1.hideOnMouseOut=true; mm_menu_1107105559_0_1.menuBorder=1; mm_menu_1107105559_0_1.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0_1.menuBorderBgColor='#000000'; mm_menu_1107105559_0_1.bgColor='#000000'; window.mm_menu_1107105559_0_2 = new Menu("VOX",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0_2.addMenuItem("VOX.co.uk","location='http://www.voxamps.co.uk'"); mm_menu_1107105559_0_2.addMenuItem("VOX online Newsletter","location='http://www.f3studios.com/vox'"); mm_menu_1107105559_0_2.addMenuItem("Pricelist","location='http://www.korgcanada.com/e/products/pricelists.html'"); mm_menu_1107105559_0_2.hideOnMouseOut=true; mm_menu_1107105559_0_2.menuBorder=1; mm_menu_1107105559_0_2.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0_2.menuBorderBgColor='#000000'; mm_menu_1107105559_0_2.bgColor='#000000'; window.mm_menu_1107105559_0_3 = new Menu("SAMSON",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0_3.addMenuItem("SAMSON WIRELESS","location='http://www.samsontech.com/products/brandpage.cfm?brandID=1'"); mm_menu_1107105559_0_3.addMenuItem("SAMSON AUDIO","location='http://www.samsontech.com/products/brandpage.cfm?brandID=2'"); mm_menu_1107105559_0_3.addMenuItem("Pricelist","location='http://www.korgcanada.com/e/products/pricelists.html'"); mm_menu_1107105559_0_3.hideOnMouseOut=true; mm_menu_1107105559_0_3.menuBorder=1; mm_menu_1107105559_0_3.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0_3.menuBorderBgColor='#000000'; mm_menu_1107105559_0_3.bgColor='#000000'; window.mm_menu_1107105559_0_3a = new Menu("HARTKE",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0_3a.addMenuItem("HARTKE","location='http://www.samsontech.com/products/brandpage.cfm?brandID=3'"); mm_menu_1107105559_0_3a.addMenuItem("Pricelist","location='http://www.korgcanada.com/e/products/pricelists.html'"); mm_menu_1107105559_0_3a.hideOnMouseOut=true; mm_menu_1107105559_0_3a.menuBorder=1; mm_menu_1107105559_0_3a.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0_3a.menuBorderBgColor='#000000'; mm_menu_1107105559_0_3a.bgColor='#000000'; window.mm_menu_1107105559_0_4 = new Menu("LIGHTSNAKE",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0_4.addMenuItem("LIGHTSNAKE","location='http://www.soundtech.com'"); mm_menu_1107105559_0_4.addMenuItem("Pricelist","location='http://www.korgcanada.com/e/products/pricelists.html'"); mm_menu_1107105559_0_4.hideOnMouseOut=true; mm_menu_1107105559_0_4.menuBorder=1; mm_menu_1107105559_0_4.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0_4.menuBorderBgColor='#000000'; mm_menu_1107105559_0_4.bgColor='#000000'; window.mm_menu_1107105559_0 = new Menu("root",150,17,"Verdana, Arial, Helvetica, sans-serif",11,"#92c4f5","#2a495f","#2a495f","#99ccff","left","middle",3,0,500,0,0,true,true,true,0,false ,true); mm_menu_1107105559_0.addMenuItem(mm_menu_1107105559_0_1,"location='http://www.korg.com'"); mm_menu_1107105559_0.addMenuItem(mm_menu_1107105559_0_2,"location='http://www.voxamps.co.uk'"); mm_menu_1107105559_0.addMenuItem(mm_menu_1107105559_0_3,"location='http://www.samsontech.com'"); mm_menu_1107105559_0.addMenuItem(mm_menu_1107105559_0_3a,"location='http://www.samsontech.com/products/brandpage.cfm?brandID=3'"); mm_menu_1107105559_0.addMenuItem(mm_menu_1107105559_0_4,"location='http://www.soundtech.com'"); mm_menu_1107105559_0.addMenuItem("Promotions","location='/e/promotions.html'"); mm_menu_1107105559_0.addMenuItem("Suggested Retail Prices","location='/e/products/pricelists.html'"); mm_menu_1107105559_0.hideOnMouseOut=true; mm_menu_1107105559_0.childMenuIcon="/images/nav/arrows.gif"; mm_menu_1107105559_0.menuBorder=1; mm_menu_1107105559_0.menuLiteBgColor='#2a4960'; mm_menu_1107105559_0.menuBorderBgColor='#000000'; mm_menu_1107105559_0.bgColor='#000000'; mm_menu_1107105559_0.writeMenus(); } // mmLoadMenus() //--> Hey guys! i'm trying to put a search box on my web site but every time i type any thing, it opens the search results on the same page. How can i make the search contents open on a fresh page?
I guess this case applies to both popup windows opened by window.open() and by showModalWindow(). I have two buttons in popup window, "Cancel" and "Save". If the user clicks either button, there is a "process" at parent window before close() at popup being called. The problem now is, if the user click the "X" sign at top right corner of that popup window, how to trigger the "process"? I think I can do nothing in popup window since the closure is unexpected programmatically. Can I put some kind of listener in parent window to detect if popup is closed? Hi! I'm new to this, so please bare with me. My terminology may not be up to par. Here's the deal: - I have a button on my Flash site that opens an HTML page in a popup window. In Flash, I open the new window using Actiosnscript 2.0: Code: on (release) { getURL("example1.html", "_blank"); } - Within the popup window are links to other HTML pages. They all open in the same window. I've been using the following to create the links in Dreamweaver: Code: onClick="MM_goToURL('parent','example2.html')" - On each page, I have a "Return to Main Menu" button that should close the popup window. To do this, I have been using: Code: onClick="window.close()" - The problem is that it works differently in each browser, and I can't even get it to consistently close the window in most browsers: Internet Explorer = popup message appears, asking "Are you sure you want to close this window?" or something similar; window closes after clicking "Yes." Safari = Only closes if I'm on the original HTML page. If I click on any of the other links (note that these all open in the same window), those pages' "Return to Main Menu" buttons cease to work. However, if I keep clicking "Back" until I get to the original page, it closes. Opera = Button actually works for each page. Firefox & Chrome = Does not close the window at all. I looked into it and saw that others have used a window.opener to solve similar issues. But, since my popup window is opened using Flash/AS2, I need to find a way around it. I've tried preceding "window.close()" with "window.opener=null" (i.e. - onClick="window.opener=null; window.close()"), but I don't think I'm doing it right because it still doesn't work. I've also seen others use codes that involve functions and variables, but it is beyond my current coding knowledge to implement this. Like I said, I'm sort of new at this. Any advice would be greatly appreciated. Thank you. - PW Hi, window.clipboardData.getData("text") is giving undefined on remote server(unix). When deployed locally(windows xp) it is coming giving correct value. In both cases the brower is IE running on windows xp. Is there anything wrong in the way I am reading the clipboard data? Situation: adding code to an HTML page that I can add to, but not change any existing code, as it is from a vendor and gets generated on the fly. I need to add a button within the existing <form></form> construct that already has a submit button and the form has an "action=" in it. What I have done is added <input type=button onClick=myscript().... Myscript() opens a .php file as a popup, positions it correctly, and all that. What it doesn't do is move the values to the .php like a method=POST would. Is there anyway to to do this, or do I have to do a set of document.write statements? Existing code: Code: <!-- vendor's untouchable code --> <form method=post name="MainForm" action="xxx.asp?yyy" onsubmit="the_vendors_code();> <input type="text" name="fielda" value="" > <!-- several more fields --> <!-- my code --> <SCRIPT type="text/javascript" SRC="xxx.js"></SCRIPT> <SCRIPT type="text/javascript"> function popupForm(myForm, windowName) { var scrny=0 ; var scrnx=200 <-! code to set scrny and scrnx based on browser --> fielda_h.value = fielda.value ; <!-- etc ..> <!-- here's the place I need help --> newWin= window.open("myPopup.php", windowName, 'height=600,width=550,and a whole bunch of other parameters') ; newWin.moveTo(scrnx, scrny) ; myForm.rel="nofollow" target=windowName; return true ; } </script> <input type="hidden" name="fielda_h" > <input type="button" name="preview" value="See Preview" onClick="popupForm(this, 'join')"/> Note that some of the code was taken from examples found on the net, so there's not a ton of originality here. So, again, just to restate, I know how to do a submit button/form to do action=post, but I am trying to simulate it with a regular button as I cannot change the existing <form></form> construct. Thanks for any and all pointers. Hi, my employer found a shell html file with just a script on it as in the title PHP Code: <script type="text/javascript"> window.location="/controlPanel" </script> Can anyone tell me what this might be doing? He said he doesnt even remember uploading this file to his site. I tried googleing the code, but didn't find specifically what it is. I think maybe its a redirect of sorts, but not sure, and definately not sure why we have it or how we have it. Thanks for any help! NOTE: This is not homework Hi all, I am trying to make a popup window. The current function I have simply opens a new window (i.e. window.open(url, ...)). What I've been trying to do is create an iframe, set it's attributes to "display: none" (so it's hidden), then create a DIV and copy the innerHTML of the iframe to the DIV. The problems I am having a (1) e.setAttribute('display', 'none') (where e is the iframe element) does not work. When I append it, it shows anyway. (2) The "innerHTML" of the iframe is empty, even though it shows on the screen (of course, I set e.src properly). I need a little guidance... how to do what I'm trying to do... which is basically display the contents of a URL in a DIV rather than a new document.window. The URL, by the way, is local (i.e same domain). This should be simple, but I'm not seeing it. BTW, here's the test code (which doesn't work) Code: var e = document.createElement('iframe'); e.src = url; e.setAttribute('display', 'none'); document.body.appendChild(e); alert(e.innerHTML); Thanks...... -- Roger Hi I'm just making a little test script, I want to add friends on myspace here my script so far: Code: <script> /*Start own function*/ var x = 0; function loadUniquePage(username) { var visits = x+1; if (visits > 1){ opener=null; } if (opener && !opener.closed){ opener.focus(); } else if (opener && opener.closed){ opener=null; } else { var page = "http://www.myspace.com/my/friends/addtofriends/" + username; var myWin = window.open(page,'','width=800,height=600,scrollbars=1'); opener = myWin; $('#Hint').html('Click follow and then close www.myspace.com/my/friends/addtofriends/' + username + ' to get coins'); check_if_open(page, username); } } function check_if_open(page, username) { var hauser = setInterval(function() { if (opener && opener.closed){ $('#Hint').html('You closed it'); opener=null; clearInterval(hauser); } }, 1000); } /*End own function*/ </script> <div id="Hint"></div> <a href="javascript:void(0);" onclick="loadUniquePage('isroyalrecords');" >Add to Friend</a> Now my question is can I somehow know which site is open, because when I'm not logged in to myspace www.myspace.com/my/friends/addtofriends/' + username + ' redirects me to the homepage of myspace? Hi Ive found out how to force another browser window to open at a certain size when a link is clicked. Here's the whole line of code including the layer, the javascript and the image, <div id="Layer6" style="position:absolute; width:10px; height:8px; z-index:6; left: 561px; top: 310px"><a href="javascript:;" onClick="MM_openBrWindow('navigation%20instructions.htm','','width=50,height=50')"><img src="images/info.gif" width="15" height="15" border="0"></a></div> How do I adapt this so I can also specify the x&y co-ordinates of the opened window relative to the window that launched it. thanks alot Masten I am using a window.open to trigger a mailto: command. I don't want the window to stay open so I try to close it right after. The default email client launches correctly, but the window stays open and I get the following Javascript error: Unable to get value of the property 'close': object is null or undefined Code: Code: var win = window.open(mailto_link,'emailWindow'); win.close(); This is my first post. I am reading "Javascript The Good Parts" ~ The Method Invocation Pattern Page 28 and tried this, var myObject= { value:0, increment:function(inc){ this.value+= typeof inc==="number" ? inc:1; } } myObject.increment(2); alert(myObject.value); but alert(myObject.value); is returning a value of "2", when it should return "3". Can someone help? Reply With Quote 12-22-2014, 09:59 AM #2 rnd me View Profile View Forum Posts Visit Homepage Senior Coder Join Date Jun 2007 Location Urbana Posts 4,497 Thanks 11 Thanked 603 Times in 583 Posts 0+2=2, not 3; the code is working correctly. I am running on Magento eCommerce, however please don't turn away if you have no experience with it. Problem is with JavaScript. When one clicks on the button, nothing happens, when the page loads browsers in general display error message, that 'productAddtoCartForm' is null or not an object Here's the piece of code around the Add button: Code: <div class="product-view"> <div class="product-essential"> <form action="http://myhairpalace.com/index.php/default/checkout/cart/add/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/product/57/" method="post" id="product_addtocart_form" enctype="multipart/form-data"> <div class="no-display"> <input type="hidden" name="product" value="57� /> <input type=" hidden"="" id="related-products-field" product-shop"=""> <div class="product-name"> <h1>100% Human Hair Lace Front Wig-Suzie</h1> </div> <p class="email-friend"><a href="http://myhairpalace.com/index.php/default/sendfriend/product/send/id/57/cat_id/11/">Email to a Friend</a></p> <p class="no-rating"><a href="http://myhairpalace.com/index.php/default/review/product/list/id/57/category/11/#review-form">Be the first to review this product</a></p> <p class="availability in-stock">Availability: <span>In stock</span></p> <div class="price-box"> <span class="regular-price" id="product-price-57"> <span class="price">$75.00</span> </span> </div> <ul class="add-to-links"> <li><a href="http://myhairpalace.com/index.php/default/wishlist/index/add/product/57/" class="link-wishlist">Add to Wishlist</a></li> <li><span class="separator">|</span> <a href="http://myhairpalace.com/index.php/default/catalog/product_compare/add/product/57/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/" class="link-compare">Add to Compare</a></li> </ul> <div class="short-description"> <h2>Quick Overview</h2> <div class="std">Suzie</div> </div> </div> <div class="product-img-box"> <p class="product-image product-image-zoom"> <img id="image" src="http://myhairpalace.com/media/catalog/product/cache/1/image/9df78eab33525d08d6e5fb8d27136e95/l/a/lace_front-shan.jpg" alt="100% Human Hair Lace Front Wig-Suzie" title="100% Human Hair Lace Front Wig-Suzie"></p> <p class="zoom-notice" id="track_hint">Double click on above image to view full picture</p> <div class="zoom"> <img id="zoom_out" src="http://myhairpalace.com/skin/frontend/default/default/images/slider_btn_zoom_out.gif" alt="Zoom Out" title="Zoom Out" class="btn-zoom-out"> <div id="track"> <div id="handle"></div> </div> <img id="zoom_in" src="http://myhairpalace.com/skin/frontend/default/default/images/slider_btn_zoom_in.gif" alt="Zoom In" title="Zoom In" class="btn-zoom-in"> </div> <script type="text/javascript"> //<![CDATA[ Event.observe(window, 'load', function() { product_zoom = new Product.Zoom('image', 'track', 'handle', 'zoom_in', 'zoom_out', 'track_hint'); }); //]]> </script> <div class="more-views"> <h2>More Views</h2> <ul> <li> <a href="#" onclick="popWin('http://myhairpalace.com/index.php/default/catalog/product/gallery/id/57/image/56/', 'gallery', 'width=300,height=300,left=0,top=0,location=no,status=yes,scrollbars=yes,resizable=yes'); return false;" title=""><img src="http://myhairpalace.com/media/catalog/product/cache/1/thumbnail/56x/9df78eab33525d08d6e5fb8d27136e95/l/a/lace_front-shan.jpg" width="56" height="56" alt=""></a> </li> </ul> </div> </div> <div class="clearer"></div> <div class="product-options" id="product-options-wrapper"> <script type="text/javascript"> //<![CDATA[ var DateOption = Class.create({ getDaysInMonth: function(month, year) { var curDate = new Date(); if (!month) { month = curDate.getMonth(); } if (2 == month && !year) { // leap year assumption for unknown year return 29; } if (!year) { year = curDate.getFullYear(); } return 32 - new Date(year, month - 1, 32).getDate(); }, reloadMonth: function(event) { var selectEl = event.findElement(); var idParts = selectEl.id.split("_"); if (idParts.length != 3) { return false; } var optionIdPrefix = idParts[0] + "_" + idParts[1]; var month = parseInt($(optionIdPrefix + "_month").value); var year = parseInt($(optionIdPrefix + "_year").value); var dayEl = $(optionIdPrefix + "_day"); var days = this.getDaysInMonth(month, year); //remove days for (var i = dayEl.options.length - 1; i >= 0; i--) { if (dayEl.options[i].value > days) { dayEl.remove(dayEl.options[i].index); } } // add days var lastDay = parseInt(dayEl.options[dayEl.options.length-1].value); for (i = lastDay + 1; i <= days; i++) { this.addOption(dayEl, i, i); } }, addOption: function(select, text, value) { var option = document.createElement('OPTION'); option.value = value; option.text = text; if (select.options.add) { select.options.add(option); } else { select.appendChild(option); } } }); var dateOption = new DateOption(); //]]> </script> <script type="text/javascript"> //<![CDATA[ var optionFileUpload = { productForm : $('product_addtocart_form'), formAction : '', formElements : {}, upload : function(element){ this.formElements = this.productForm.select('input', 'select', 'textarea', 'button'); this.removeRequire(element.readAttribute('id').sub('option_', '')); template = '<iframe id="upload_target" name="upload_target" style="width:0; height:0; border:0;"><\/iframe>'; Element.insert($('option_'+element.readAttribute('id').sub('option_', '')+'_uploaded_file'), {after: template}); this.formAction = this.productForm.action; var baseUrl = 'http://myhairpalace.com/index.php/default/catalog/product/upload/'; var urlExt = 'option_id/'+element.readAttribute('id').sub('option_', ''); this.productForm.action = parseSidUrl(baseUrl, urlExt); this.productForm.target = 'upload_target'; this.productForm.submit(); this.productForm.target = ''; this.productForm.action = this.formAction; }, removeRequire : function(skipElementId){ for(var i=0; i<this.formElements.length; i++){ if (this.formElements[i].readAttribute('id') != 'option_'+skipElementId+'_file' && this.formElements[i].type != 'button') { this.formElements[i].disabled='disabled'; } } }, addRequire : function(skipElementId){ for(var i=0; i<this.formElements.length; i++){ if (this.formElements[i].readAttribute('name') != 'options_'+skipElementId+'_file' && this.formElements[i].type != 'button') { this.formElements[i].disabled=''; } } }, uploadCallback : function(data){ this.addRequire(data.optionId); $('upload_target').remove(); if (data.error) { } else { $('option_'+data.optionId+'_uploaded_file').value = data.fileName; $('option_'+data.optionId+'_file').value = ''; $('option_'+data.optionId+'_file').hide(); $('option_'+data.optionId+'').hide(); template = '<div id="option_'+data.optionId+'_file_box"><a href="#"><img src="var/options/'+data.fileName+'" alt=""><\/a><a href="#" onclick="optionFileUpload.removeFile('+data.optionId+')" title="Remove file" \/>Remove file<\/a>'; Element.insert($('option_'+data.optionId+'_uploaded_file'), {after: template}); } }, removeFile : function(optionId) { $('option_'+optionId+'_uploaded_file').value= ''; $('option_'+optionId+'_file').show(); $('option_'+optionId+'').show(); $('option_'+optionId+'_file_box').remove(); } } var optionTextCounter = { count : function(field,cntfield,maxlimit){ if (field.value.length > maxlimit){ field.value = field.value.substring(0, maxlimit); } else { cntfield.innerHTML = maxlimit - field.value.length; } } } Product.Options = Class.create(); Product.Options.prototype = { initialize : function(config){ this.config = config; this.reloadPrice(); }, reloadPrice : function(){ price = new Number(); config = this.config; skipIds = []; $$('.product-custom-option').each(function(element){ var optionId = 0; element.name.sub(/[0-9]+/, function(match){ optionId = match[0]; }); if (this.config[optionId]) { if (element.type == 'checkbox' || element.type == 'radio') { if (element.checked) { if (config[optionId][element.getValue()]) { price += parseFloat(config[optionId][element.getValue()]); } } } else if(element.hasClassName('datetime-picker') && !skipIds.include(optionId)) { dateSelected = true; $$('.product-custom-option[id^="options_' + optionId + '"]').each(function(dt){ if (dt.getValue() == '') { dateSelected = false; } }); if (dateSelected) { price += parseFloat(this.config[optionId]); skipIds[optionId] = optionId; } } else if(element.type == 'select-one' || element.type == 'select-multiple') { if (element.options) { $A(element.options).each(function(selectOption){ if (selectOption.selected) { if (this.config[optionId][selectOption.value]) { price += parseFloat(this.config[optionId][selectOption.value]); } } }); } } else { if (element.getValue().strip() != '') { price += parseFloat(this.config[optionId]); } } } }); try { optionsPrice.changePrice('options', price); optionsPrice.reload(); } catch (e) { } } } function validateOptionsCallback(elmId, result){ var container = $(elmId).up('ul.options-list'); if (result == 'failed') { container.removeClassName('validation-passed'); container.addClassName('validation-failed'); } else { container.removeClassName('validation-failed'); container.addClassName('validation-passed'); } } var opConfig = new Product.Options({"80":{"447":0,"448":0,"451":0,"452":0,"449":0,"450":0,"454":0,"453":0}}); //]]> </script> <dl> <dt><label>Color<span class="required"> *</span></label></dt> <dd class="last"> <select name="options[80]" id="select_80" class=" required-entry product-custom-option" title="" onchange="opConfig.reloadPrice()"><option value="">-- Please Select --</option><option value="447">1 </option><option value="448">1B </option><option value="451">1B/30 </option><option value="452">1B/33 </option><option value="449">2 </option><option value="450">4 </option><option value="454">4/27 </option><option value="453">4/30 </option></select> </dd> </dl> <script type="text/javascript"> //<![CDATA[ enUS = {"m":{"wide":["January","February","March","April","May","June","July","August","September","October","November","December"],"abbr":["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]}}; // en_US locale reference Calendar._DN = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]; // full day names Calendar._SDN = ["Sun","Mon","Tue","Wed","Thu","Fri","Sat"]; // short day names Calendar._FD = 0; // First day of the week. "0" means display Sunday first, "1" means display Monday first, etc. Calendar._MN = ["January","February","March","April","May","June","July","August","September","October","November","December"]; // full month names Calendar._SMN = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]; // short month names Calendar._am = "AM"; // am/pm Calendar._pm = "PM"; // tooltips Calendar._TT = {}; Calendar._TT["INFO"] = "About the calendar"; Calendar._TT["ABOUT"] = "DHTML Date/Time Selector\n" + "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + "For latest version visit: http://www.dynarch.com/projects/calendar/\n" + "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + "\n\n" + "Date selection:\n" + "- Use the \xab, \xbb buttons to select year\n" + "- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" + "- Hold mouse button on any of the above buttons for faster selection."; Calendar._TT["ABOUT_TIME"] = "\n\n" + "Time selection:\n" + "- Click on any of the time parts to increase it\n" + "- or Shift-click to decrease it\n" + "- or click and drag for faster selection."; Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)"; Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)"; Calendar._TT["GO_TODAY"] = "Go Today"; Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)"; Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)"; Calendar._TT["SEL_DATE"] = "Select date"; Calendar._TT["DRAG_TO_MOVE"] = "Drag to move"; Calendar._TT["PART_TODAY"] = ' (' + "Today" + ')'; // the following is to inform that "%s" is to be the first day of week Calendar._TT["DAY_FIRST"] = "Display %s first"; // This may be locale-dependent. It specifies the week-end days, as an array // of comma-separated numbers. The numbers are from 0 to 6: 0 means Sunday, 1 // means Monday, etc. Calendar._TT["WEEKEND"] = "0,6"; Calendar._TT["CLOSE"] = "Close"; Calendar._TT["TODAY"] = "Today"; Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value"; // date formats Calendar._TT["DEF_DATE_FORMAT"] = "%b %e, %Y"; Calendar._TT["TT_DATE_FORMAT"] = "%B %e, %Y"; Calendar._TT["WK"] = "Week"; Calendar._TT["TIME"] = "Time:"; //]]> </script> <p class="required">* Required Fields</p> </div> <script type="text/javascript">decorateGeneric($$('#product-options-wrapper dl'), ['last']);</script> <div class="product-options-bottom"> <div class="price-box"> <span class="regular-price" id="product-price-57_clone"> <span class="price">$75.00</span> </span> </div> <div class="add-to-cart"> <label for="qty">Qty:</label> <input type="text" name="qty" id="qty" maxlength="12" value="1" title="Qty" class="input-text qty"> <button type="button" title="Add to Cart" class="button btn-cart" onclick="productAddToCartForm.submit()"><span><span>Add to Cart</span></span></button> <p class="paypal-logo"><a id="ec_shortcut_c2e3fb1be4b9e9d53800cbc4d5f1e274" href="http://myhairpalace.com/index.php/default/paypal/express/start/"> <img src="https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&buttontype=ecshortcut&locale=en_US" alt="Checkout with PayPal"> </a> <input type="hidden" id="pp_checkout_url" name="return_url" value=""> <script type="text/javascript"> //<![CDATA[ Event.observe('ec_shortcut_c2e3fb1be4b9e9d53800cbc4d5f1e274', 'click', function(event) { $('pp_checkout_url').value = this.href; productAddToCartForm.submit(); event.stop(); }); //]]> </script></p> </div> </div> </form> <script type="text/javascript"> //<![CDATA[ var productAddToCartForm = new VarienForm('product_addtocart_form'); productAddToCartForm.submit = function(){ if (this.validator.validate()) { this.form.submit(); } }.bind(productAddToCartForm); //]]> </script> </div> <div class="product-collateral"> <div class="box-collateral box-description"> <h2>Details</h2> <div class="std"> Nautral Hairline 100% Human Hair Lace Front wig. </div> </div> <div class="box-collateral box-tags"> <h2>Product Tags</h2> <form id="addTagForm" action="http://myhairpalace.com/index.php/default/tag/index/save/product/57/uenc/aHR0cDovL215aGFpcnBhbGFjZS5jb20vaW5kZXgucGhwL2RlZmF1bHQvaW5kaWFuLXJlbXktZnJvbnQvMTAwLWh1bWFuLWhhaXItbGFjZS1mcm9udC13aWctc3V6aWUuaHRtbD9fX19TSUQ9VQ,,/" method="get"> <div class="form-add"> <label for="productTagName">Add Your Tags:</label> <div class="input-box"> <input type="text" class="input-text required-entry" name="productTagName" id="productTagName"> </div> <button type="button" title="Add Tags" class="button" onclick="submitTagForm()"> <span> <span>Add Tags</span> </span> </button> </div> </form> <p class="note">Use spaces to separate tags. Use single quotes (') for phrases.</p> <script type="text/javascript"> //<![CDATA[ var addTagFormJs = new VarienForm('addTagForm'); function submitTagForm(){ if(addTagFormJs.validator.validate()) { addTagFormJs.form.submit(); } } //]]> </script> </div> </div> </div> Magento uses Prototype framework and the problem has something to do with prototype.js file and indeed, when I debugged in Chrome, here's what came up: Now, the crux is that the error shows up only pages featuring products w/ options in dropdown menus: http://myhairpalace.com/index.php/de...inkerbell.html You are able to add Simple Products to cart just fine: http://myhairpalace.com/index.php/de...o-measure.html I would be incredibly grateful for ANY suggestions. +++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++first window+++++++++++++++++++++++++ +++++++++++++++++++second window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT' onClick='window.open('third.html', '')'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++second window++++++++++++++++++++ ++++++++++++++++++++++third window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> ++++++++++++++++++++++third window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the text box and 'OK' button clicked, the second window opens with 2 text box and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the third window. Please help me out. Thanks. God bless in Jesus name. *ADDED* Though i am advised to add 'window .open' as one of the arguments to the OK button which i did yet it doesn't work somebody please help me out! I am using Mozilla 3.6 could this mean that it doesn't support this? +++++++++++++++++++++++++++first window+++++++++++++++++++++++++ <html> <head> <script language="javascript"> var myWindow; function christDoes(){ mydWindow=open("second.html", "yes"); } </script> </head> <body><form name="myform" method=POST ACTION="sake.html" ><CENTER> <B>ENTER YOUR SUBJECT</B><INPUT TYPE="TEXT" NAME="subject"> <input type="button" name="ok" value="OK" onClick="christDoes()"> </form> </body> </html> +++++++++++++++++++++++++++parent window+++++++++++++++++++++++++ ++++++++++++++++++++++++++++child window++++++++++++++++++++++ <html> <head> <script language="javascript"> function me(){ displayColor(); } function displayColor() { callWindow=window.open("third.html","fine"); } var m=0; var fSubject = self.opener.document.forms[0].subject.value; if(fSubject.length>0){ if(isNaN(fSubject)){fSubject="";} else{opener.alert("Please enter figure");} numSub=parseInt(fSubject); if(numSub==2){var strSub="ab";} self.document.write("<center>" +"ENTER SUBJECT HERE" +"</center><br>"); var mercy="<HTML><BODY>" mercy +="<FORM ACTION='save.html' METHOD='POST'>" mercy +="<CENTER>" sub=new Array(strSub.length); for(var i=0; i<sub.length; i++){ m++; mercy +=m +"<input type='text' name='sub[i].toLowerCase()'>" +"<BR>"; opener.alert("You have entered" +m +"subjects"); } } mercy +="</CENTER></FORM></BODY></HTML><BR></BR>"; self.document.write(mercy +"<BR>"); self.document.bgColor="pink"; self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onload='me()'> </body> </html> ++++++++++++++++++++++++++++++child window++++++++++++++++++++ +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ <html> <head> <script language="javascript"> function help(){ self.document.write("this is me") self.document.write("<center>" +"<input type='button' name='submit' value='SUBMIT'>" +"<center>"); } </script> </head> <body onLoad="help"> </body> </html> +++++++++++++++++++++++++++++++new window+++++++++++++++++++++ Can somebody help me with the code to make this button work? In the parent window when 2 is input in the textbox and 'OK' button clicked, the second window opens with 2 textbox and 'SUBMIT' button. If 'SUBMIT' button is clicked in the child window i want it to open the new window. Please help me out. Thanks. God bless in Jesus name. window.open() doesn't open an entirely new window in FF3.6, just a new tab suggestions? Edit: Yeah, ok, so if i specify a size smaller than the current standard window, it'll be forced to open a new window. but what if i want a new standard sized window to open entirely? and in any case, i wan t amore direct solution where possible, thanks. Hello everyone. I'm new to programming, although I've learned HTML and CSS pretty thoroughly. I think I have most of the Javascript basics down as far as definitions, but I'm getting hung up on the actual coding. I'm working on an information request form for my fiancee's business site. In it, I want to have options that users select via radio buttons. Rather than having additional input fields static on the page, I would like to program some of the radios, when clicked, to open a previously unseen option where users will then be able to type in the necessary information. More specifically, since she only works in two states, I want a third option of "other," which, when opened, will allow the user to input any other state. Then, should the radio be deselected or reset, the field would disappear again. If my understanding is correct, I think I will need to use a javascript function in the header, an HTML "div" section with ID, "onclick" and "offclick" events in the button mark-up, and the specific javascript code to call the function (getElementById?). Or maybe I'm way off. Please help. Thanks suggestions welcome !!
Hey All, I replied in another thread asking about this, but I figured it would be best to have a separate thread for it. I'm trying to use lightbox (Video Lightbox) to not just open a video when clicking on a thumbnail image, but a mock "page" of several videos, where the main video plays, but there are surrounding thumbnail images that can then also be selected to play in the main player. Has anyone ever done anything like this? I've seen it done elsewhere, but wasn't sure how to actually implement it. Any suggestions would be appreciated. Thanks. |