JavaScript - Problem Opening 2 Separate Windows.
Hello. I am opening a new small window through javascript. Here is the code:
Code: <script type="text/javascript"> function openwindow(id) { var left = (screen.width/2)-350; var top = (screen.height/2)-240; var mywindow = window.open(" map.asp ?location="+id,"mywindow","menubar=0,resizable=0,width=700,height=400,left="+left+",top="+top+"");} </script> But on the same page I have another link for a new window which is essentially the same code: Code: <script type="text/javascript"> function openwindow(id) { var left = (screen.width/2)-350; var top = (screen.height/2)-240; var mywindow = window.open(" pofull.asp ?poid="+id,"mywindow","menubar=0,resizable=0,width=700,height=400,left="+left+",top="+top+"");} </script> As you can see in the red text, one link should open map.asp and the other should open pofull.asp... but they BOTH open in pofull. So I have tried to change the function name for one of them but then it doesnt work at all. I am quite confused here. I have tried everything to separate the two scripts but nothing has worked. Can someone help? Similar TutorialsHello everyone, I'm very new to Javascript, and I'm trying to build a simple webpage with frames with navigation links that open in other frames. I have three frames in the main part of my webpage, A, B, and C. Frame A is the header, Frame B is where I keep the links, and Frame C is where I want the links to display. I'm trying to get the links in Frame B to work both as text links and as radio button links. So far, I have managed to get the text links to open in Frame C as I wanted to, but when it comes to the radio buttons, I encounter a problem. The radio buttons do open as links... Except, they open in the frame they're contained, Frame B, rather than in Frame C like I want them to. Does anyone know how I might fix this problem? Is the coding completely wrong or is it just a simple mistake I've overlooked? Here is the relevant code: This is the code for the main page with the frames: Code: <html> <frameset rows="100,*"> <frame src="Hello.htm" NAME="A"/> <frameset cols="25%,75%"> <frame src="Linklist.htm" NAME="B"/> <frame src="Start.htm" NAME="C"/> </frameset> </frameset> </html> And this is the code for my links: Code: <html> <head> <SCRIPT LANGUAGE="JavaScript"> function go(loc) { window.location.href = loc; } </script> </head> <BODY BGCOLOR="#000000" TEXT="#green"> <p><center><h4>Links</h4></center></p> <form name="form"> <input type="radio" name="loc" onClick="go('http://www.wikipedia.org/');" TARGET="C"> <A HREF="http://www.wikipedia.org/" TARGET="C">Wikipedia</A><br> <input type="radio" name="loc" onClick="go('http://dictionary.reference.com/'); TARGET="C""> <A HREF="http://dictionary.reference.com/" TARGET="C">Dictionary.com</A><br> </form> </html> Any and all help would be much appreciated. This has me really stumped. Thank you for your time! You can see the website here with all the code to make it easier for you to diagnose what is happening: Code: http://www.fdfdaa.com/desktop/desktop.html When you go to the start menu and select anything on the left side, you will see that windows open 100% of the screen by default. I did that by adding maximized:true but that doesn't appear to be working for the icons on the desktop itself. If you click on one of those 4 icons on the desktop though, it isn't opening at 100% for some reason. You can see my classes file here as well: Code: http://www.fdfdaa.com/desktop/classes.js Any help will be greatly appreciated. Thank you for your time! Doing a bit of window-opening: the idea is, when a link is clicked, it selects a random one from an array of urls, and then opens it with certain toolbars missing. Got a script for each part, but not sure how to combine them: ' location ' seems to be talking about different things in each script. the random script: Code: var single = new Array ("a.htm","b.htm","z.htm") function choose(){ window. location =choose[Math.floor(Math.random()*single.length)] } the opener script: Code: function open() { window.open('myurl',' location =no,toolbar=1, directories=no,status=no,menubar=no,resizable=yes,scrollbars=yes') } Any suggestions? (No comments plz about removing toolbars: still experimenting, and the viewer won't be left stranded). 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 I am currently designing a website for our public library. I have added a card catalog search bar on the side of every page. Our catalog software company has supplied the code. After embedding it, I previewed each page to make sure it was working properly. At the time, it worked fine. Since then, I have added other elements to the homepage such as a Twitter feed and a Flickr slideshow. Now, when I attempt to search in the catalog search bar on the homepage, it opens two tabs, but only in Firefox. Our IT person from the software company suggested I make a copy of the page and strip the code down to see what the problem is. After doing this, I have made no headway. Even with the catalog as the only code left on the page, other than text, it still opens two tabs. The following is the code embedded on the homepage: Code: <div> <script type='text/javascript'> function gotoserver() { sn = document.getElementById('server').value; redirecturl = 'http://webopac.infovisionsoftware.com/stephenville/default.aspx?Title='+sn; window.open(redirecturl) //document.location.href=redirecturl; } </script> <input type='text' name='server' id='server' /> <input type='submit' id='mySearch' value='Go' onclick='javascript:gotoserver();' /> </div> I would appreciate any advice given. Thank you for your time. I am facing problem in IE6.x.x. when opening pdf document for modaldialog. Some security warning appears and the PDF not getting open. Can you suggest how to solve this problem. This happens only in some machine. We checked all the browser settings in the PC.Any suggesstions please? Getting : Security Warning instead of opening PDF. In the warning pop up i can see file name : my URL[The PDF open URL formed in java side with the report name and pasing parameters] File type : Un known file type If i click "open", or "save" or "Cancel" the window is getting closed. I checked the browser setting also. Everything is fine. Please note : This happens only in some machine, not every time.The problem only occurs first time for the user and from next time he is not getting this problem again[Rare case]. All documents are getting opened successfully. Please post me if any body facing this problem and let me know the solutions if any. Thanks in advance. Hi Everyone, I have the following problem that I have been trying to figure out for a few hours now and am hoping someone can give me a help out. I am opening a popup - this popup is solely to take an image url and as such has one field. On this 1st popup I have a 'button' which when clicked launches a 2nd popup window containing a file browser. The user selects the file by double clicking on the image they want, the url is passed back to the 1st popup, poulating the field and the 2nd popup is closed. Work perfectly in FF etc.. but in IE7 and IE8 it will not work. I am using the following function, linked to the button in the 1st popup, to open the 2nd popup window pass across the name of the field and the window object to the 2nd window. Code: function popupTwoInit(file_path, field_name, win) { var w = window.open(file_path, null, 'toolbar=yes,menubar=yes,width=900,height=600'); w.fileFileField = field_name; w.fileFileWin = win; } Where w is holding the window object created by the window.open, field_name is the name of the field on the popup that I wish to pass back a value to and win is the window object of the 1st popup. I am using this function as the callback to poulate the field in the 1st dialog after an image in the 2nd dialog has been selected: Code: filebrowser_callback(url) { window.fileFileWin.document.forms[0].elements[window.fileFileField].value = url; window.fileFileWin.focus(); window.close(); } So this function accesses the passed through window object and field name from the window.open function, populates the field, gives the 1st popup focus and closes the 2nd popup. I thought about using opener in the 2nd popup to access the window object and field in the 1st popup but opener seems to refer to the main page in the browser - perhaps because I am using 2 popups OR I have got that wrong. Like I say works perfectly in FF but IE is always undefined for both 'window.fileFileWin' & 'window.fileFileField' which seems to suggest that the object is not interpreted by IE in the first function? I am a PHP developer with limited Javascript knowledge so any help would be great. Thanks very much. This is my test page: http://www.thesacstudio.com/ccid_web...ndex_copy.html Am using Dynamic Drive's smooth menu javascript When viewed on a PC using IR the menu makes the page "jump" i am a Mac guy and at my limit of what to do. thanks for any assistance Hi, I have read (and been told) that the current standard/fashion is to have separate files for html, css and javascript but nobody has ever said why that is... it would seem to me to be easier to keep everything in one file, but there must be advantages to separating them out. Does anybody feel like breaking them down for me? thanks in advance. Hey all, So basically, what I effectively want is a dropdown menu, but without it dropping down. Let me put it a different way, I have my top links, and a space underneath them. What I want is for if you move your mouse over one of the links a new set of links relative to that one will appear in the box below and will remain there until the mouse is moved over another main link. Is this possible? Thanks I want to make separate js and html files from my toggle.htm file: Code: <html> <head> <script type="text/javascript"> function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; } } </script> </head> <body> <a id="displayText" href="javascript:toggle();">show</a> <== click Here <div id="toggleText" style="display: none"><h1>peek-a-boo</h1></div> </body> </html> My togglejs.js file looks like this: Code: function toggle() { var ele = document.getElementById("toggleText"); var text = document.getElementById("displayText"); if(ele.style.display == "block") { ele.style.display = "none"; text.innerHTML = "show"; } else { ele.style.display = "block"; text.innerHTML = "hide"; } } My togglehtm.htm file looks like this: Code: <html> <head> <script type="text/javascript" src="toggle.js"></script> </head> <body> <a id="displayText" href="javascript:toggle();">show</a> <== click Here <div id="toggleText" style="display: none"><h1>peek-a-boo</h1></div> </body> </html> What changes should I make. Please help. Hi, I'm fairly new to javascript & am trying to learn it using best methods. I have been using various books & some video tutorials, such as lynda.com. I've noticed when I do google searches for example tutorials, 9 times out 10, the javascript has been coded into the html file. As a newbie I find it takes a very long time to redo the coding into the separate .js file. And if the coding is relatively complex (and most of it appears that way to someone new to this) I can't get it too work using a separate file for the javascript. I wanted to ask anyone very familiar with this, their suggestions regarding good places for tutorials where the .js file is separated. Apparently there are advantages to having it separate and it's considered best practices from what I've come to understand. Also most of the results from google searches pulls up out-dated coding and/or tutorials that suggest you should already understand what is being referred too. I'm trying to avoid learning it the wrong way. I'm willing to put in the effort, however I don't want to pick up bad habits. Any help is very appreciated. If this was not as clear as I intended it to be, please ask any specifics and I'll try my best to answer. -Todd Hi On my web page I have 3 seperate catorgories with 2 drop down lists in each, the first dropdown list in each catergory is for "county" here is a snippet of the code Code: function fillCategory(){ addOption(document.drop_list.Category, "bedfordshire", "Bedfordshire", ""); addOption(document.drop_list.Category, "berkshire", "Berkshire", ""); addOption(document.drop_list.Category, "buckinghamshire", "Buckinghamshire", ""); addOption(document.drop_list.Category, "cambridgeshire", "Cambridgeshire", ""); I wanted to know if it is possible to use "list.js" to populate all 3 county dropdown lists or would I need "list.js" "list1.js" etc etc HTML5&JS-Game-1 Large JS Into Separate JS Files? Hi, I am a C++ game programmer who attempted to make an HTML5/JS game. Game turned out great (except for some performance issues on old computers). Although the game is good, I am terribly embarrassed about the source. Source is HTML5/JavaScript and its one giant, ugly, and confusing HTML file. I've been researching on Google how to split the 1 large HTML file into smaller separate *.js files but can not get it working. Here is the URL link to the game's folder on my web site: http://16bitsoft.com/T-Crisis3AI--HTML5/ I've tried to split the one HTML file into smaller separate *.js files. Had a "Logic.js" file with all logic global variables and functions in it and I loaded the "Logic.js" file (I think) into main HTML file but the main HTML file can't locate the logic variables and functions??? If your a Jedi Master Ninja Assassin HTML5/JavaScript coder then please try to help! Thanks! JeZ+Lee 16BitSoft Video Game Design Studio www.16BitSoft.com Here is screenshots of the game: Hi, I was working on this problem that asks me to return an array of scores for each string (only for its content part, not URL) in the global variable, which is an array. For example, alert a score of 0 if the string z is not found, 1 if found once, and 2 for twice. My problem is that I can get the code to alert if it has found the word (ex. "the"), but I cannot manage to : a) Assign separate scores for each string. b) Make the search case insensitive i.e. "the" will appear in 0,1, but not in 2, where it is capitalized I would appreciate any help! [CODE] var c = ["[www.facebook.com] Facebook is the best social networking site to coccent with your friends. ", "[www.google.co.uk] Google is the worldwide search engine. ", "[www.bbc.co.uk] The best news source for starting your day. "]; function findScore(z) { for (var i=0; i<c.length; i++) { var a = c[i].toString(); var b = a.search(z); if(b>-1) { alert (z + " found in array " + i); } } } findScore("the"); [CODE] Sorry for not being able to wrap the code! so, I can pass a value from a select list to another function which then decides which function to call, but I want to cut out the middleman, and make the values the function calls, and call them directly on the onchange... I imagine something like this: Code: <select id="select" onchange="this.value"> <option selected value="function1()">Funtion 1</option> <option value="function2()">Function 2</option> <option value="function3()">Function 3</option> </select> is it possible? Hi, I'm writing a page scraper in javascript which involves loading a page to scrape, detecting when the page has loaded successfully and then scraping the data. I can get the 'page loading detection' to work if I load the page in a sub-frame. But this is no good as some sites include frame-buster code which breaks my scraper and I cant get any of the framebuster-buster solutions to work. So instead I decided to look at loading the page in a separate tab. Does anyone know how to reliably detect when a page has finished loading in a tab please? I am using Firefox only and I dont mind if the solution requires some extension or greasemonkey script (I have already added the configuration/commands to allow access to pages from different domains). The code below shows an attempt. It sometimes detects when the initial page has loaded but when I press 'submit' it doesnt detect the second loading. Thanks. Code: <html> <head> <script type="text/javascript"> currentPageObj = window.open("http://www.bbc.co.uk", "currentPage"); currentPageObj.addEventListener("load", function(){alert("loaded")}, false); </script> </head> <body> <form action="http://www.example.com" rel="nofollow" target="currentPage"> <input type="submit"> </form> </body> </html> Hello, I am currently trying to create a simple form based web-page (uploaded here) that creates a query for a WMS (Web Map Service). Seeing as how I am still new to programming, I was hoping that you could help me . The page consists of about 10 different forms, which are all put together in a (string) variable named "compiledQuery" in a function named "compileRequest" which is activated via a button. I would like to print out this variable on the page so that the users can see the query for themselves. After doing some research I came to the conclusion that the best way to do this would be via an iframe (I do not want to use a pop-up). The function I use to do this is: Code: function printRequest() { var query_frame = document.getElementById('frame_compiled'); query_frame.document.write(compiledQuery); } "frame_compiled" is the name of my iframe: Code: <iframe name="frame_compiled" width="400" height="125"> </iframe> I know that "compiledQuery" has been assigned a value (I used an alert with the value). Hence, I also know that the "prinRequest"-function works on principle... However, it seems as if I am having problem with retrieving the name of the iframe to the function (I tried doing an alert with the value, it was returned as null). So, I suppose my question is this: How do I properly retrieve the value of the iframe, and am I on the right way using document.write to show the value of "compiledQuery" to the users? Or should I use another way of doing this completely? I think I have looked through a hundred different tutorials and guides online, I just can't seem to find any hints to this problem... Any help would be greatly appreciated Hey everyone. I'm looking for a tutorial or open source script to accomplish the following tasks: 1 - Accordion style vertical list that expands element (Film # and description) when "+more" link is clicked, and closes the previous open film and description. 2 - Activation of "+ more" shows a photo in separate div, and hides the previous photo that was visible in this separate div. I've attached a mockup photo of the idea I need to execute. Seems like a simple idea, but I have not been able to find a similar example/tutorial online. If anyone can point me in the right direction, that would be greatly appreciated. Thanks. I have a form where users will be making a selection in a drop down box. I need, essentially, to store two values: the first value is the actual value assigned with each drop down item (their label, basically), and the second value being a completely separate value that will change based on what they chose from the drop down box to begin with. Example: Drop down box contains selections A, B, C, D. User selects A, I need to keep the original dropdown box's A value in tact for the dropdown box's value, and then store a 1 in a hidden textbox. User selects B, a 2 is stored, etc. Both of these values will be e-mailed, hence the reason I chose a hidden textbox to store the second value. Additionally, I don't want the user to see the second value on the form itself. If there's a better way to accomplish this, please let me know. |