Hello, felix:
This was a really interesting question and maybe I will use it in my
own developments. I post the code I created using Dreamweaver, I have
tested it on Mozilla, IE, and Opera and it works like a charm. Let me
explain what this code does:
-It's a simple webpage, it contains a form with an input text and a
submit button
-When the form is submited the OnSubmit event is executed and...
-It calls the routine MM_openBrWindow to open a new window with all
the features you specified, only a status bar
-Also specifies width and height (640x480)
-The URL to open is a Google search using the value the user entered
into the text field
-After open the window, the main window is redirected to another URL,
in this sample to http://answers.google.com
-The window is centered on screen using this code:
------------------------------------
var l=(screen.width-640) / 2;
var t=(screen.height-480) / 2;
features+=',left='+l;
features+=',top='+t;
------------------------------------
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<script language="JavaScript">
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
var l=(screen.width-640) / 2;
var t=(screen.height-480) / 2;
features+=',left='+l;
features+=',top='+t;
neww=window.open(theURL,winName,features);
}
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2)
eval(args[i]+".location='"+args[i+1]+"'");
}
function MM_findObj(n, d) { //v4.0
var p,i,x; if(!d) d=document;
if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++)
x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++)
x=MM_findObj(n,d.layers[i].document);
if(!x && document.getElementById) x=document.getElementById(n);
return x;
}
function MM_getProp(objName,x) { //v3.0
var obj = MM_findObj(objName);
if (obj && (obj.style))
{
return (obj.value);
}
}
//-->
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form1" method="post" action=""
onSubmit="MM_openBrWindow('://www.google.com/search?q='+MM_getProp('textfield','')+'&ie=UTF-8&oe=UTF-8&hl=en&lr=','newwindow','status=yes,width=640,height=480');MM_goToURL('parent','http://answers.google.com');return
document.MM_returnValue">
<input type="text" name="textfield">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
When copying and pasting, be aware of Google Answers word wrapping,
which may break some of the code and could cause to don't work
correctly.
I think this answers solves all the requeriments you posted, but in
any case, don't hesitate to request for a clarification, I will more
than happy to help you.
Best regards. |
Clarification of Answer by
joseleon-ga
on
06 Sep 2002 04:44 PDT
Hello:
I have sent the modified register.html page to your e-mail account,
this is how it works:
-When the form is submitted, I specify the target frame where will
throw the results of calling the action url
-This frame belongs to a newwindow created in the routine
MM_openBrWindow, after create the window, a frameset is written into
it to create a topFrame and a mainFrame. The topframe is redirected to
://www.google.com, change it with your own header.
-Also, when the form is submitted, the main page is directed to
://www.google.com with this sentence
MM_goToURL('parent','://www.google.com');
change it to the URL you want
I think this answers meets all your requeriments, make a backup of
your original register.html before update it. I have not registered
into the site, but submitting the form without data it popups the
window with an error page requesting the required data. Test it to see
if works well and request for any clarification if you want.
Respect increase the quantity of the answer, I'm not allowed to
specify a price, in Google Answers you specify the price and if a
researcher thinks the answer is worth the money, then answers it. So
you are free to increase to the quantity you think is fair for my
work, I will be happy with any increase you make.
Regards and I hope you use Google Answers again.
|