JavaScript - Dictionary Bookmarklet To Open In New Window
hi guys,
How could I make this useful dictionary bookmarklet open in a new window? javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.g etSelection())||(document.selection&&document.selection.createRange&&document.selection.createRange( ).text));var%20e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&langpair=auto|en&tbb=1&ie='+e;}; Its the "To English" bookmarklet as featured on lifehacker. Thanks! Similar TutorialsHi, I want to open a new window and then execute some js function on that window. My code looks like this: Code: windowObjectReference = window.open("http://some_page.html","name"); windowObjectReference = window.open("javascript:(some_function('param1');)","name"); Is it possible to do activate bookmarklet thru js on new window? 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. 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(); I do write some php, but have not much idea about JavaScript. I use window.open to open 10 pages simultaneously. I prefer to open them with a time delay from each other to put less load on the target server. This is my code with no delay. (I played around with setTimeout but can't get it to work.) PHP Code: <a href='http://www.".$new[9]."' onclick="window.open('http://www.".$new[0]."/'); window.open('http://www.".$new[1]."/'); window.open('http://www.".$new[2]."/'); window.open('http://www.".$new[3]."/'); window.open('http://www.".$new[4]."/'); window.open('http://www.".$new[5]."/'); window.open('http://www.".$new[6]."/'); window.open('http://www.".$new[7]."/'); window.open('http://www.".$new[8]."/')\" target='new300/'>Open 10</a> +++++++++++++++++++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. 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() { ... } Code: <a href=" javascript: myWindow = window.open('http://en59.tribalwars.net/game.php?village=3463&screen=premium&mode=transfer'); myWindow.document.forms[0].name.value='Gods Child';end" target="_blank">Donate Please</a> So, what I am trying to do is when you click the link, a new page opens to that site, then does document.forms[0].name.value='Gods Child'; I can get the page to open, but then it doesn't do the second part. If I run the second part in the url bar, when at the other site, it works how I want too, but not when I do it at the same time. NOTE: The only part that needs to be in this is document.forms[0].name.value='Gods Child'; and the link, but you can change the rest however you want. Hi All: I have a problem with a free script for an internal site search and I would like to tweek. I know nothing about javascript so be patient. What I want to do is to open a new window when you select a hyperlink in the results returned page. Here's the relevant code: Code: // ---------- script properties ---------- var include_num = 1; var bold = 0; // ---------- sites ---------- var s = new Array(); s[0] = "JSE^form.html^Enter JSE in the example above ...^open source, free, client side"; s[1] = "JSE DOCUMENTATION^doc.txt^JSE is a client-side local site search engine. Written entirely in JavaScript 1.3 it works with browsers from Netscape 4.7 to Microsoft Internet Explorer 6.0 ...^ faq, docs, instructions"; // ---------- end of script properties and sites ---------- var cookies = document.cookie; var p = cookies.indexOf("d="); if (p != -1) { var st = p + 2; var en = cookies.indexOf(";", st); if (en == -1) { en = cookies.length; } var d = cookies.substring(st, en); d = unescape(d); } var od = d; var m = 0; if (d.charAt(0) == '"' && d.charAt(d.length - 1) == '"') { m = 1; } var r = new Array(); var co = 0; if (m == 0) { var woin = new Array(); var w = d.split(" "); for (var a = 0; a < w.length; a++) { woin[a] = 0; if (w[a].charAt(0) == '-') { woin[a] = 1; } } for (var a = 0; a < w.length; a++) { w[a] = w[a].replace(/^\-|^\+/gi, ""); } a = 0; for (var c = 0; c < s.length; c++) { pa = 0; nh = 0; for (var i = 0; i < woin.length; i++) { if (woin[i] == 0) { nh++; var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa++; } else { pa = 0; } } if (woin[i] == 1) { var pat = new RegExp(w[i], "i"); var rn = s[c].search(pat); if (rn >= 0) { pa = 0; } } } if (pa == nh) { r[a] = s[c]; a++; } } co = a; } if (m == 1) { d = d.replace(/"/gi, ""); var a = 0; var pat = new RegExp(d, "i"); for (var c = 0; c < s.length; c++) { var rn = s[c].search(pat); if (rn >= 0) { r[a] = s[c]; a++; } } co = a; } function return_query() { document.jse_Form.d.value = od; } function num_jse() { document.write(co); } function out_jse() { if (co == 0) { document.write('Your search did not match any documents.<p>Make sure all keywords are spelt correctly.<br>Try different or more general keywords.'); return; } for (var a = 0; a < r.length; a++) { var os = r[a].split("^"); if (bold == 1 && m == 1) { var br = "<b>" + d + "</b>"; os[2] = os[2].replace(pat, br); } if (include_num == 1) { document.write(a + 1, '. <a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } else { document.write('<a href="', os[1], '">', os[0], '</a><br>', os[2], '<p>'); } } } You can see the search feature in action at http://qualityhealthplans.com It works great but I want to be able to select a particular page hyperlink and open it in a new window without leaving the search results page. Can anyone help? Hello, I want to know how to open a new window when someone is closing a page. I mean for example, I have to two pages, if the user closes the first page when he clicks on Close button or close in his tab, a new window will open to open the second page. Thank you.
Code: <SCRIPT language=JavaScript> function DoSearch() { if (document.frmSearchID.txtIssueID.value != "") { if (isNaN(document.frmSearchID.txtIssueID.value)) { alert('Issue Numbers must be numeric');} else {document.location = "http://www.****.com/Apps/AddIssues/EditIssue.asp?IssueID=" + document.frmSearchID.txtIssueID.value + "&ProjectID=LRUSTARS";}}} </SCRIPT> <FORM style="display:inline" target="_blank" action="http://www.****.com/default.asp?ProjectID=LRUSTARS#" name="frmSearchID" onSubmit="javascript:DoSearch();return false;" method="post"> <INPUT class="formField1" name="txtIssueID"> <INPUT class="formBox" onClick="javascript:DoSearch(); return false;" type="submit" name="search" VALUE="Search"> </form> Cant seem to get it to open in a new window any help? Hi I'm new here and need some help; I spent so long with this and need either a miracle or a javascript expert! I have the code below which is used to open up a chat window, the problem is all browser treat this as a pop up and block it! What could be changed to get round this? $chat = "window.open( '" . SK_Navigation::href("private_chat", array("userKey"=>$pr_key, "oppUserKey"=>$opp_key, 'is_esd_session'=>1 )) . "', '', 'height=540,width=415,left=100,top=100,scrollbars=no,resizable=no' );"; Thanks dr when a user click on a link, it would open a new window in HTML it is something like this: Code: <a href="http://google.com" target="_blank">click here</a> How do I do this in Javascript? So a user would click on the link and it would open a new window. Here's my code Code: document.writeln('<tr><td>' + "http://google.com" + '</td></tr>'); I know window.open(url) would open a new window, but how do I make it clickable?? Any comments or suggestion would be greatly appreciated. thanks Hi all, I found this bookmarklet which I'm using in Firefox. Would anyone here be willing to modify it to display its results in a new tab, instead of using the current tab? Thanks in advance. Code: javascript:q=""+(window.getSelection?window.getSelection():document.getSelection? document.getSelection():document.selection.createRange().text);if(!q) q=prompt("Search terms [leave selection and box blank to list all pages] ...").replace(/\s\+/g,"%252B");if(q!=null)location="http://www.google.com /search?q="+q.replace(/\s+/g,"+")+"+site:"+location.hostname;void(0); Hi Folks, here is the weirdest problem. I want open a url in the same window, replacing the current page. To test this I have created a simple script. The setup: I have two files in the same folder. abc.html and xyz.html. abc.html contains a button that calls this script: Code: function openWindow() { window.open( "xyz.html" ) ; } And this works fine, just as a test. But I want to open xyz.html in the same window, replacing abc.html . So I try: Code: window.open( "xyz.html" , "_self" ) ; does not work but simply reloads abc.html. I try: Code: window.location.href = "xyz.html"; does not work, but, again, simply reloads abc.html. What gives? The odd thing is, when it reloads the same page, abc.html, the address bar displays this at the end of the address: abc.html?button=Submit Any ideas on what may be going wrong here, or how I can get this to work? All this is being tested locally on my laptop - MacBook - and have tested in Safari and Firefox with the same results for both. Thanks in advance! I am writing a script which deals with reading text and extracting information from it. What I want this script to accomplish is outlined below: 1.) The user uploads a .txt file containing an article in a newspaper or a expert from a book etc. 2.) The text is then printed onto the page 3.) After a button is clicked, all the verbs in the article are highlighted (This doesn't have to be very precise, and will involve the script reading from a verb dictionary/list and highlighting any matches if finds.) 4.) The total amount of verbs is printed at the bottom. The issues I am having is planning a way to set up this verb dictionary. I was thinking of using an array but would like to avoid it if at all possible as I am dealing with strings not numbers, and I do not want to go into creating a database if it can be avoided. Does anyone have suggestions on how I can go about setting up some kind of verb list that the script can read from? (On a side note, if there is another language that may be better suited for this kind of program, I have experience in Java and C but would prefer to use JavaScript.) 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. How do I open a window from within a .js file? I want to do this, below in a .js file like I would in a html file. <a href="google.co.uk" class="thickbox"></a> 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 |