JavaScript - Can Javascript Links Open In Parent Window?
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?
Similar TutorialsI am completely a beginner at coding and really do not know much right now. This is the day of week link rotation script which works just great: Code: <script type="text/javascript"> <!-- var MyEveryDayLinks = [ ['Sunday', 'http://www.google.com', 'Google'], ['Monday', 'myURL', 'LinkName'], ['Tuesday', 'myURL', 'LinkName'], ['Wednesday', 'myURL', 'LinkName'], ['Thursday', 'myURL', 'LinkName'], ['Friday', 'myURL', 'LinkName'], ['Saturday', 'myURL', 'LinkName'] ]; var today = new Date(); var L = today.getDay(); document.write('Today is ' + MyEveryDayLinks[L][0] + '. My daily URLs: <a href="' + MyEveryDayLinks[L][1] + '">' + MyEveryDayLinks[L][2] + '<\/a>.') ; // --> </script> Unfortunately I can't open urls in a new window. I would so like this to work...but don't know why i can't make it work. I've tried something like this with no luck...any ideas?: Code: <a href="javascript:[window.open(' + MyEveryDayLinks[L][1] + ', 'height=200, width=200',)];">' + MyEveryDayLinks[L][2] + '<\/a>.') ; Hi, How can I set the following widget so it opens the links (pages) in a new window? Code: <SCRIPT charset="utf-8" type="text/javascript" src="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822/US/oweg0a-20/8018/9000c5f7-9ce1-4eb6-887f-0491e54add7d"> </SCRIPT> <NOSCRIPT><A HREF="http://ws.amazon.com/widgets/q?ServiceVersion=20070822&MarketPlace=US&ID=V20070822%2FUS%2Foweg0a-20%2F8018%2F9000c5f7-9ce1-4eb6-887f-0491e54add7d&Operation=NoScript">Amazon.com Widgets</A></NOSCRIPT> Thanks in advance! Regards Rain Lover I need help turning the following inline code: Code: <a href="http://www.bing.com/" name="bing" onclick="return !window.open(this.href)">Bing</a><br> <a href="http://www.lycos.com/" name="lycos" onclick="return !window.open(this.href)">Lycos</a><br> <a href="http://www.dogpile.com/" name="dogpile" onclick="return !window.open(this.href)">DogPile</a><br> into an external javascript function that will do the same thing (open all links in a new window individually if javascript is enabled, without destroying links in html for if javascript is not enabled). Any smarties out there have any good suggestions? Hi there, I am trying to open some SWF videos from an HTML page. When the user clicks the link, I would like to have the videos open in a transparent window (not a separate browser wndow). I have figured out how to embed the files and have them open in a transparent window as soon as you load/refresh the page but I want to open the SWF using a link. Any suggestions? Thank you all. B Let me start of by saying that I'm a designer, not a programmer so I'll apologize in advance for having very little knowledge of javascript. I found a free script for a auto-advancing slideshow that allows you to give each image in the slideshow a unique link. My problem is that when you click on one of the pictures the link opens in a new window instead of loading in the default browser window. I have tried to search google for an answer but my lack of javascript knowledge has left me scratching my chin. Here's the code in the head of my page: Code: <script language="JavaScript1.1"> <!-- /* JavaScript Image slideshow */ var slideimages=new Array() var slidelinks=new Array() function slideshowimages(){ for (i=0;i<slideshowimages.arguments.length;i++){ slideimages[i]=new Image() slideimages[i].src=slideshowimages.arguments[i] } } function slideshowlinks(){ for (i=0;i<slideshowlinks.arguments.length;i++) slidelinks[i]=slideshowlinks.arguments[i] } function gotoshow(){ if (!window.winslide||winslide.closed) winslide=window.open(slidelinks[whichlink]) else winslide.location=slidelinks[whichlink] winslide.focus() } //--> </script> and here's the Body code: Code: <script> <!-- //configure the paths of the images, plus corresponding target links slideshowimages("images/services/3d_meter.jpg", "images/services/3d_prototype.jpg", "images/services/3d_stage_renderings.jpg", "images/services/atsite.jpg", "images/services/netstar.jpg", "images/services/photo_manipulation.jpg", "images/services/powerpoint.jpg") slideshowlinks("/", "/", "/", "/", "/", "/", "/") //configure the speed of the slideshow, in miliseconds var slideshowspeed=8000 var whichlink=0 var whichimage=0 function slideit(){ if (!document.images) return document.images.slide.src=slideimages[whichimage].src whichlink=whichimage if (whichimage<slideimages.length-1) whichimage++ else whichimage=0 setTimeout("slideit()",slideshowspeed) } slideit() //--> </script> fooling around with it, I think I have determined that my problem is the window.open in the function gotoshow, but again, I'm a designer who has little knowledge of how this actually works. If it helps, here is a link to my site where I have the slideshow, http://gravescreativedesign.com/services.html All of the images link to the index page for my site at the moment for testing purposes, but these images will eventually link to different urls within my portfolio section of my website. 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 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. 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 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> 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 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 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 } 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. 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 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 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! i have this code i need to close the parent.html window when the child window opened, i need the code for that working well in IE and Firefox Parent.html <HTML> <SCRIPT TYPE="text/javascript"> function sendTo() { window.open('child.html','_blank','resizable=yes,width='+(screen.width-500)+',height='+(screen.height-500)+''); } </SCRIPT> <BODY > <form name="form"> <input type="text" value="" name="text1" id="pdetails1"> <input type="text" value="" name="text1" id="pdetails2"> </br> <input type="submit" value="submit" onClick="sendTo()"> </BODY> </HTML> child.html <html> <body> <form> <input type=text name="text5" value=""> <input type=submit name="submit"value="submit"> </form> </body> </html> After following the instructions from the answer below: http://bytes.com/topic/javascript/an...arent-document I was able to have the child window perform the function defined in the parent window. The function was to only have an alert window pop up as the child page was loading. I easily modified this to my intention which was to have a parent function performed when the child window was clicked. Using the body tag: Code: <body onclick="parent.FUNCTION NAME HERE()"> I first change the method in which the function would be triggered, all went well there. then I tried to change which function would be triggered. (Basically use the function I wanted to happen on click of the child window rather then the function from the test). Once I did this switch, nothing happens. The site this is being used on is: http://tylerpanesar.ca/ What I want is when the menu bar is open in the parent window, the user chooses a link and the menu closes and goes to that link in the child window. This already works. However if the user opens the menu bar and then changes there mind and continues with the page the are currently on (clicks any content in the child window), the menu stays open. Currently the menu "hides" only when you choose one of the menu items, but it does not "hide" when you CLICK on child document. If you could figure out how to get it to "hide" on a "mouse out" that would be the better option. I attempted this method however i could only get it to "toggle" the menu on "mouse out". This method does however create an annoying flicker when you hover over the menu items (as it is toggling the open menu command I guess). If I had it "hide" the menu on "mouse out" it would "hide" as soon as you moved off of the main button. The viewer doesn't even have a chance to click a link. or at least that is what happens when I did it. You may have a better method to achieve this. The script that tells it to hide on click is within a jQuery function: Code: menua .click( function(){ menu.hide(); the code I used for the mouseout toggle was: Code: menu .mouseout( function(){ menu.toggle(); Here is the script that I am currently using for the menu to open and the "click" hide feature. This menu feature comes from the following help: http://www.bennadel.com/blog/1740-Bu...-FaceBook-.htm Code: <script type="text/javascript"> jQuery(function( $ ){ var menuRoot = $( "#menu-root" ); var menu = $( "#menu" ); var menua = $( "#menu a" ); // Hook up menu root click event. menuRoot .attr( "href", "javascript:void( 0 )" ) .click( function(){ // Toggle the menu display. menu.toggle(); // Blur the link to remove focus. menuRoot.blur(); // Cancel event (and its bubbling). return( false ); } ) ; menua .click( function(){ // Toggle the menu display. menu.hide(); } ) ; // Hook up a click handler on the document so that // we can hide the menu if it is not the target of // the mouse click. $( document ).click( function( event ){ // Check to see if this came from the menu. if ( menu.is( ":visible" ) && !$( event.target ).closest( "#menu" ).size() ){ // The click came outside the menu, so // close the menu. menu.hide(); } } ); }); </script> I've tried adding the click to "hide" menu feature to the child document but there is now menu in that document for it to "hide". What I was trying to was have the child document execute a function from the parent document and have that function executed IN the parent document. I've tried the technique from the link in my very first post but I believe it only calls the function from the parent and executes it IN the child. Which does not work for me as the menu is not in the child. There should be a way to make the child execute a function FOR the parent. I apologize for this very wordy post, but I am extremely frustrated with this now as I have been trying to get this to work for a few weeks now. Any help would be greatly appreciated. Thanks in advance, Tyler |