JavaScript - Javascript Onclick=window.open, Problem With Mouse Right-hand Context Menu
Using onclick=window.open function in js to open a pdf file link in a new popup window.
Works fine to display the file onscreen, but not if the user wants to save the file client-side to their computer. The right-hand-button context menu for the mouse will allow the user to download, but the file saved will be a html dump file for the webpage and the name of the file will be that for the webpage. Of course I can use the easy <a href> method for download links and the mouse context menu options will be as expected, but I can only use target="-blank" or target="_self" . I need a popup window to open. Could use : oncontextmenu="alert('Left click the link to open, and then SAVE from with the pdf viewer') to advise users how to save the file, and could use "javascript: void(0)" to eliminate most mouse context menu options, so the user won't bother try. So how can I get a link to a file which can be viewed in a popup window and downloaded using mouse right-hand context menu? Any advice massively appreciated! Similar TutorialsHi, I'm having troube closing the main Internet Explorer window using a script called from a right click menu. The code I'm using is: Code: <script language="JavaScript"> var oWindow = window.external.menuArguments; oWindow.close(); </script> When the script calls, windows prompts to close the window, but when 'yes' is clicked the Alert sound sounds and the window remains open! If the script is called from a button on the page it will close, but I want to close any page on the internet using a right click! All help will be gratefully received. Dave. I'm trying to pass the URL of a link to a function, then delay opening the window. I get an undefined error. Any help would really be appreciated. Here is my code: PHP Code: <head> <script> function openWin(test) { setTimeout("window.open(test)", 5000); } </script> </head> <body> <a href="http://www.example.com" onClick="openWin(this); return false;">Test</a> </body> Hello, I've tried various things I've found online but cannot seem to get the right code to open the links in a drop down menu in a new window. Code: <form id="quicklinks" name="quicklinks" action=""> <select name="quicklinkitem" onchange="openWin(quicklinkitem.value)"> <option value="/lib/board.html">Select a Date</option> <option value="/lib/boardreports/03-08-12.pdf">March 8, 2012</option> <option value="/lib/boardreports/02-09-12.pdf">February 9, 2012</option> </select> </form> I appreciate any help. Elbee Hello, I have an asp page to search for data. I like to open it in a new window while retain the search values. And I also can resize the window as well as set its attributes like height, width,etc. I created a js function like this: function posttopopup(formname, windowname) { if (! window.focus)return true; window.open('', windowname); formname.rel="nofollow" target=windowname; return true; } on my asp search page: <form method="post" action=search.asp" onSubmit="posttopopup(this, 'popupwindow')"> ..... <input type="button" name="Submit1" value="Search" onclick="if (isDate()) document.Search.submit();"> I keep getting errors like "document.search has no value..." What did I do wrong? Thanks. hi. i am looking for help (example) to open to a new window in the original window. the original window is blocked from any user inputs. a good example is here at http://www.dominos.com/home/index.jsp and click on "locations" button. is there a special name for this window.open? thanks On my website, I have a domain name registration field that links to a reseller storefront and then searches for that domain name. I would like the storefront to open in a new window, instead of the parent window. I have tried to insert the target="blank tag but can not seem to get it to work. Is there another way to make that window open? I would appreciate any help to make this function work. You can see the page and field he http://websites4magicians.com/inprogress/ The field is on the left side, just below the center of the page. Thanks for the help! I have found this Alarm Clock from JavaScript Kit and when the alarm time is reached it redirects to the URL entered. I would like to keep the alarm clock running, have it open a new window for the entered URL such as (Target="Blank") in HTML. Can someone help? var jsalarm={ padfield:function(f){ return (f<10)? "0"+f : f }, showcurrenttime:function(){ var dateobj=new Date() var ct=this.padfield(dateobj.getHours())+":"+this.padfield(dateobj.getMinutes())+":"+this.padfield(dateo bj.getSeconds()) this.ctref.innerHTML=ct this.ctref.setAttribute("title", ct) if (typeof this.hourwake!="undefined"){ //if alarm is set if (this.ctref.title==(this.hourwake+":"+this.minutewake+":"+this.secondwake)){ window.location=document.getElementById("musicloc").value } I have a webpage that display a Reporting Services report viewer page inside an iFrame. In the report that displays there is a link to a product image that needs to pop-up in a new window. Reporting Services will only allow me access to the url value of the link so we have been using the code below to open the new window. Thing is the code works fine when the parent iFrame is in the same site, OR another IIS site on the same server. It will not work when the iFrame page and the page with the link are on different servers (which with my luck is the setup I need to have for business reasons...). I've stripped this down to an empty iFrame holding a page with just the link and the behavior stays the same. Is there something in the syntax below that is causing the issue, or is there another way to go about popingthe link up in a new window using only the url? Thanks, Chris Code: <a tabindex="7" href="javascript:void(window.open('http://webreporting.domain.com:81/images/PIE0522.jpg', '_blank','location=no,toolbar=no,left=100,top=100,height=200,width=200'))" style="text-decoration:none;color:Black" TARGET="_top">PIE0522</a> Hi everyone I am a newbie with respect to programming and this is my first post I have a small problem, probably very basic to everyone except me, and would appreciate and value your advice I have entered below a javascript I am using on my website. This script is designed to automatically insert videos based on keywords and works perfectly except that my visitors are taken away from my website when they use it. Can someone please tell me what code to insert, and where, in order get the script to open in a new page. I am aware how to do this in html using target ="blank" but do not know how to do it in javascript. Thankyou in anticipation, the code I am using is below: Code: <!-- BEGIN HostDomain --> <div id="HostDomain_DivId"> </div> <script src="http://app.HostDomain.com/script/HostDomainUtils.js"> </script> <script language="JavaScript" type="text/javascript" src="http://app.HostDomain.com/script/widgetTy pe/carousel/ptContentflow.js" load="fancyScrollbar"> </script> <script type="text/javascript"> /* Do not change the values given below. */ var HostDomain_Organization_Name = "MySite"; var HostDomain_Organization_ID = "xxxxxxxx"; var HostDomain_Feed_ID = "xxxxxxx"; var HostDomain_DivId = "HostDomain_DivId"; var HostDomain_AppServerPath = "http://app.HostDomain.com"; </script> <script src="http://app.HostDomain.com/script/HostDoma in.js"> </script> <!-- END HostDomain --></font></td> Hi I am a new bie to Javascript programming. We have a scenario to launch a new browser window for a given HTML. I have the following approaches : Approach 1: my_window = window.open("", "report"); my_window.document.open(); my_window.document.write("<HTML> <BODY> HI </BODY></HTML>"); my_window.document.close(); Approach 2: var newWindow = window.open("", "report"); newWindow.document.body.innerHTML = "<HTML> <BODY> HI </BODY></HTML>"; Could anyone sugges Which is the correct approach ? Our requirement is to have this code to work in any browser? Thanks I have a JSP page,such as test.jsp Code: <input name="id1" type="text" value="abc" size="40"> Then I want to open it by using Javascript,and alert id1 value,so I use following statements: Code: var s=window.open('test.jsp','mywin'); alert(s.document.id1.value); When I run alert(s.document.id1.value),,it raise javascript error Code: s.document.id1.value undefined I want to know how Javascript can get jsp value by window.open? Thanks Hi, Sorry if this is quite a basic thing to some of you guys, but I've been searching the web for a couple of days now and I can't find an answer that covers my wants completely. I am coding a website in c#/.net. I have a couple of functions which need a new window opening: 1) a send to a friend form; 2) a contact us form. I have chosen to open a new window in both cases because the user is positioned on a list item when they click the button. In order to keep the number of windows to a minimum, they both call the same window name, let's say "popup". Both the windows are different sizes. I have constructed an open window function which is called when each link is clicked, shown below: var nw=window.open(this.href,this.target,'width=680,height=541,resizable=1');nw.focus();nw.resizeTo(698, 631);return false; The second one is the same but with different sizes. The above code whould open a new window, however if its already open and is the other size window, it should resize. When going from the smaller to larger window it does resize, however the larger window never decreases in size. The issue is currently being tested in Firefox. Ideally I would like to take it one step further (like Facebook bookmarking) where a window is opened then dynamically resized (length only) to fit the content. If I can't achieve this then the first solution to maintain the correct widow size across both forms would be ok. Thanks in advance. is there a way in HTML or Javascript to open a new tab (or new window) and force it to be a new tab (or new window) after alert confirmation of javascript? onclick="window.open('google.com', '_blank'); return false;" OR document.location.href = "google.com"+"&target='_blank'"; not working Code: <?php if ($_POST[oke]) { ?> <script language="JavaScript">alert('thanks'); document.location='google.com' </script> <?php } ?> <form target="_self" method="post"> <input type="submit" name="oke" value="save"> </form> how to put the target _blank Instead of using window.open, which I understand opens a new window, is there a code that will make the link open in the parent window?
Hi, Can you please help me to solve the window.open() problem with firefox browser? I wrote the statement which is given below, window.open('filename.php','file_head','width=730,height=525,status=no,location=no,menubar=no,resiza ble=no'); Only width & height parameters were working in firefox & others are not working. This was working properly in IE. Problem exisitng with firefox only. Please let me know if anyone have solution for this problem Hi! everyone. I've run into a problem with a piece of script and being code illiterate I could use some help. I'm making a page with a few thumbnails that I want to use as links to open a larger image in a pop-up window. I found this piece of code ( call it a senior moment ~ but I didn't make a note of where it was ) that works fine in Firefox and Safari, but IE8 is telling me that there is an error in the highlighted line: Code: <script language="JavaScript"> function openW(mypage,myname,w,h,features) { if(screen.width){ var winl = (screen.width-w)/2; var wint = (screen.height-h)/2; }else{winl = 0;wint =0;} if (winl < 0) winl = 0; if (wint < 0) wint = 0; var settings = 'height=' + h + ','; settings += 'width=' + w + ','; settings += 'top=' + wint + ','; settings += 'left=' + winl + ','; settings += features; win = window.open(mypage,myname,settings); win.window.focus(); } </script> Code: <a href="JavaScript:openW('URL','TITLE',WIDTH,HEIGHT,'')">LINK</a> Anyone got an idea if it can be tweaked to make IE recognize it? Or a simple alternative script that works cross browser? Any help would be greatly appreciated. Thanks I am facing an issue where a link on my website opens in a new window if you simply click on it. However, if you right click and say open in new window or new tab, it opens the same window (URL) again from where the link is clicked. Self Service Option is a link and the JSP calls a function getSelfServSite() when the link is clicked. This is how the code flows in my case function getSelfServSite() { getToTheLink("${myConfigInfo.selfServiceURL}"); // this is because the URL is configurable } function getToTheLink(url) { window.open (url, "currentWindow", ""); } What am I doing wrong. I want it to go to the right link no matter how the user click it. Please advise. Thanks Hello I'm having problems with a very simple bit of Javascript not working with the latest version of Safari for ipads and iphones. The script in question is used as a 'previous image ' and 'next image' navigation facility, basically closing one pop-up window and opening up another, when viewing a photo gallery. It has worked perfectly for a number of years on all browsers. It is only the latest version of Safari for ipads and iphones where there's a problem. On an iphone, the new window unfortunately opens up in a new tab and the existing window fails to close. Mobile Safari soon reaches the maximum of 8 permissible tabs as a user moves through the photos gallery. On an ipad2, no new window opens and the existing window fails to close. the website is www.gethigh.co.uk Code: } function picPopup4(page,width,height){ //alert(scroll); var a; a = width / 2; var b; b = height / 2; var LeftPosition = (screen.width/2) - a; var TopPosition = (screen.height/2) - b; window.open(page, "", "width="+width+",height="+height+",toolbar=no,header=no,location=no,resizable=yes,"+"left="+LeftPosition +",top="+TopPosition+",scrollbars=yes"); window.close(); } and this is an example of the code creating the navigation within each pop-up window Code: <tr> <td align="center"><a class="link8" href="javascript:picPopup4('legslip1.html','560','770');" target="_self"> previous image</a> <a class="link8" href="javascript:window.close()">close window</a> <a class="link8" href="javascript:picPopup4('breaking2.html','505','800');" target="_self">next image</a></td> </tr> I'll come clean and admit I'm not a programmer and have a very basic and ancient understanding of HTML coding. My website must be approaching double digit years old (which will be immediately apparent if you view its structure). I can usually resolve most things, and maintain its functioanality when needs be, but this particular problem has got me stumped. I've come onto this forum to see if anyone could provide a simple work-around ? Or if anyone would know if this is a bug within Safari which may be rectified soon (a search through the Apple forums gave no clues). I'm loathed to make any major updates/changes to my site, as despite its age it renders beautifully on all browsers except the latest ipad/iphone Safari. Cheers and hopefully thanks in advance Garry .... |