rejetto forum

Help for JavaScript

Alons0 · 9 · 7295

0 Members and 1 Guest are viewing this topic.

Offline Alons0

  • Tireless poster
  • ****
    • Posts: 197
    • View Profile
    • Alons0's site
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?


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
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>');
}
« Last Edit: May 09, 2007, 01:17:30 PM by That_Stevens_Guy »


Offline Alons0

  • Tireless poster
  • ****
    • Posts: 197
    • View Profile
    • Alons0's site
Please show me how can i run it completely? I can't do it alone
« Last Edit: May 09, 2007, 01:53:22 PM by Alons0 »


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
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 :)


Offline Alons0

  • Tireless poster
  • ****
    • Posts: 197
    • View Profile
    • Alons0's site
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?


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
sorry :P nope its 2.29am i am just doing my quick forum check then heading to bed.


Offline Alons0

  • Tireless poster
  • ****
    • Posts: 197
    • View Profile
    • Alons0's site
sorry :P nope its 2.29am i am just doing my quick forum check then heading to bed.
I'm still waiting ::)


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
<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.