rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: Alons0 on May 09, 2007, 12:43:45 PM

Title: Help for JavaScript
Post by: Alons0 on May 09, 2007, 12:43:45 PM
I wanna when i enter in my site to be open one more window for information (like popup but i don't wanna be allert) How can I make this by JavaScript?
Title: Re: Help for JavaScript
Post by: TSG on May 09, 2007, 01:11:31 PM
HTML /  JAVASCRIPT:
<body onload="window.open('***URL OF HTML FILE***','****WINDOW NAME****','width=640,height=480,left=100,top=100,scrollbars=yes,resizable=yes')">

That should do it, just make a html document and put the url in the javascript, then when the page loads they see this... only problem is they will see it for EVERY page load, but with some further javascript you could fix this have a function like the below psuedocode.

HTML:
<body onload="popUp('some variable');">

JAVASCRIPT:
function popUp (some variable) {
if (some variable = "something" /*this is the login page*/) {
        window.open('***URL OF HTML FILE***','****WINDOW NAME****','width=640,height=480,left=100,top=100,scrollbars=yes,resizable=yes');
} else {
        return null;
}

I could show you how to do it completely with javascript but it gets quite complex very quickly.

But i will post an example code of how to build html and css in a popup fully in javascript anyway :P this is a registration form idea we had a looong time ago, if you can make it from that code, go for it!

Code: [Select]
function openBox() {
popup=window.open('','Contact','height=325,width=490,resizable=yes,scrollable=yes');
var win = popup.document;
win.write('<html><head><title>Registration</title>'); win.write('<style>body{margin:0px;padding:0px;font-size:12px;font-family:Tahoma;background-color:#ECF0F6;height:100%;color:#036;}.infobox{border:1px solid #fff;padding:5px;}.infohder{border-top:1px solid #fff;border-left:1px solid #fff;border-right:1px solid #fff;}.content{background-color:#EAEDF4;border:1px solid #004480;margin:10px;}th{background-color:#036;color:#fff;height:30px;border-left:1px solid #fff;}</style>');
win.write('</head><body>');
win.write('<div class=content><table cellspacing=0 cellpadding=0 border=0 width="100%"><tr><th class=infohder align=center>Registration Form</th></tr><tr><td class=infobox align=left>');
win.write('<form id="feedback" name="feedback" method="post" action="mailto:" enctype="text/plain" onSubmit="return checkForm()">');
win.write('<br><label>Real Name: <input name="field_name" type="text" size="25"/></label><br><br>');
win.write('<label>Desired Password: <input name="field_password" type="text" size="10"/> 10 characters max.</label><br><br>');
win.write('<label>Login Name: <input type="text" name="field_login" size="20"> (if different from Real NAME)</label><br><br>');
win.write('<label>Connection Speed: <input type="text" name="field_speed" size="6"/> kbps.<label><br><br>');
win.write('<label>E-mail: <input name="field_email" type="text" id="sender" size="25"/></label><br><br>');
win.write('<center><input type="submit" name="submit" value="Submit" />&nbsp;&nbsp;&nbsp;<input name="reset" type="reset" value="Reset"/>&nbsp;&nbsp;&nbsp;<input type="button" name="cancel" value="Cancel" onclick="javascript:self.close()"></center>');
win.write('</form></td></tr></table></div></body></html>');
}
Title: Re: Help for JavaScript
Post by: Alons0 on May 09, 2007, 01:48:31 PM
Please show me how can i run it completely? I can't do it alone
Title: Re: Help for JavaScript
Post by: TSG on May 09, 2007, 03:00:57 PM
I'm sorry i cant help now, if you haven't sorted it out by tomorrow night, i will make it work. But its 1am and im sleeping :)
Title: Re: Help for JavaScript
Post by: Alons0 on May 11, 2007, 04:09:47 PM
I'm sorry i cant help now, if you haven't sorted it out by tomorrow night, i will make it work. But its 1am and im sleeping :)
Are you free yet?
Title: Re: Help for JavaScript
Post by: TSG on May 11, 2007, 04:31:02 PM
sorry :P nope its 2.29am i am just doing my quick forum check then heading to bed.
Title: Re: Help for JavaScript
Post by: Alons0 on May 16, 2007, 02:56:30 PM
sorry :P nope its 2.29am i am just doing my quick forum check then heading to bed.
I'm still waiting ::)
Title: Re: Help for JavaScript
Post by: TSG on May 16, 2007, 04:02:38 PM
<script  type="text/javascript">
function PopUp() {
   if (window.location.href == 'http://%host%/') {
      popup = window.open('','PopUp','height=325,width=490,resizable=yes,scrollable=yes');
      win = popup.document;
      win.write('<html><head><title>PopUp</title>');   
      win.write('<style>body{margin:0px;padding:0px;}</style></head><body>');
      win.write('<div>STUFF IN POPUP</div>');
      win.write('<div>STUFF IN POPUP</div>');
      win.write('</body></html>');
   } else {
      return null;
   }   
}
</script>

<body onload="PopUp();">

The above will run only if on the root of your server. Sorry for the delay i am REALLY busy lately.
Title: Re: Help for JavaScript
Post by: Alons0 on May 16, 2007, 07:21:15 PM
Thank you!