Click to See Complete Forum and Search --> : using win.document.write() with window.open()


neil9999
11-28-2003, 01:08 PM
Hi,

I've got a button in the Links toolbar with the following URL specified:

javascript:var locofwin2=location.href;window.open("",null,"height=200, width=500 status=yes top=200");win.document.write('<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\"><meta name=\"GENERATOR\" content=\"Microsoft FrontPage 4.0\"><meta name=\"ProgId\" content=\"FrontPage.Editor.Document\"><title>New Page 1</title></head><body><form name=\" box\"><p><select name=\"lg\" id=lg> <option value=\"en_zh\">English to Chinese</option> <option value=\"en_fr\">English to French</option> <option value=\"en_de\" SELECTED>English to German</option> <option value=\"en_it\">English to Italian</option> <option value=\"en_ja\">English to Japanese</option> <option value=\"en_ko\">English to Korean</option> <option value=\"en_pt\">English to Portuguese</option> <option value=\"en_es\">English to Spanish</option> <option value=\"zh_en\">Chinese to English</option> <option value=\"fr_en\">French to English</option> <option value=\"fr_de\">French to German</option> <option value=\"de_en\">German to English</option> <option value=\"de_fr\">German to French</option> <option value=\"it_en\">Italian to English</option> <option value=\"ja_en\">Japanese to English</option> <option value=\"ko_en\">Korean to English</option> <option value=\"pt_en\">Portuguese to English</option> <option value=\"ru_en\">Russian to English</option> <option value=\"es_en\">Spanish to English</option></select></p><input type=\"text\" name=\"box2\" size=\"20\" id=box2 value=\"'+locofwin2+'\"><button onclick=\"window.open(\'http://babelfish.altavista.com/babelfish/tr?doit=done&urltext=\'+document.getElementById(\'box2\').value+\'&lp=\'+document.getElementById(\'lg\').value)\">translate</button></form></body></html>');window.location=location.href;

The button, when clicked, should open a popup with the following code written using win.document.write:

<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"><meta name="GENERATOR" content="Microsoft FrontPage 4.0"><meta name="ProgId" content="FrontPage.Editor.Document"><title>New Page 1</title></head><body><form name=" box"><p><select name="lg" id=lg> <option value="en_zh">English to Chinese</option> <option value="en_fr">English to French</option> <option value="en_de" SELECTED>English to German</option> <option value="en_it">English to Italian</option> <option value="en_ja">English to Japanese</option> <option value="en_ko">English to Korean</option> <option value="en_pt">English to Portuguese</option> <option value="en_es">English to Spanish</option> <option value="zh_en">Chinese to English</option> <option value="fr_en">French to English</option> <option value="fr_de">French to German</option> <option value="de_en">German to English</option> <option value="de_fr">German to French</option> <option value="it_en">Italian to English</option> <option value="ja_en">Japanese to English</option> <option value="ko_en">Korean to English</option> <option value="pt_en">Portuguese to English</option> <option value="ru_en">Russian to English</option> <option value="es_en">Spanish to English</option></select></p><input type="text" name="box2" size="20" id=box2 value=""><button onclick="window.open('http://babelfish.altavista.com/babelfish/tr?doit=done&urltext='+document.getElementById('box2').value+'&lp='+document.getElementById('lg').value)">translate</button></form></body></html>

The value of the textbox should be var locofwin2. The only problem is the popup doesn't open at all when the button on the links toolbar is clicked. Does anyone know why this is?

Thanks in advance,

Neil

Ps. All the code that should be written into the popup works fine.

Khalid Ali
11-28-2003, 11:28 PM
how are you calling this line of code?

neil9999
11-29-2003, 02:28 AM
Thanks for replying,

In IE, if you right click on a button in the links toolbar (View>toolbars>links to display) then click properties, and click on the "Web Document" tab, you get a textbox labelled "URL:". It is this textbox I put the top line of code in my last post. I then clicked "apply" then OK. If you then left-click on the same button on the Links toolbar it should then carry out the top line of code from my last post. A popup should appear with the bottom line of code from my last post written using document.write. The value of the textbox in the popup should be the same as var locofwin2 from the top line of code.

I've attatched a screenshot of the "Links toolbar".

Thanks,

Neil