PDA

View Full Version : need some help!!



wishmaster2
05-04-2007, 11:41 AM
hello...i have un html project for the uni and its almost finished now...but i have to add a javascript and a php on that to complete it... without dreamweaver..i have to write the code on text document...anw my question is...how do i add javascript on a complete html site? i will Appreciate any help i can get!!! thanks!!

wishmaster2
05-05-2007, 04:39 PM
anyone!!??!!??!!

tesco
05-05-2007, 08:46 PM
Anywhere in the code, best in the <head> area, just put something like:

<script type="text/javascript">
<!--
//blah blah blah code here
-->
</script>


What do you need this javascript to do?

wishmaster2
05-06-2007, 10:07 AM
i need it to pop-up a new window...

tesco
05-06-2007, 05:01 PM
<html>
<head>
<title>Example</title>
<script type="text/javascript">
function popup_window()
{
window.open('http://filesharingtalk.com/vb3/','Window Title','width=800,height=600');
}
</script>
</head>
<body>
<a href="#" onclick="popup_window();">Open Popup Window</a>
</body>
</html>


Read here: http://www.pageresource.com/jscript/jwinopen.htm
There are more attributes you might need to add to allow the new window to scroll, have toolbars, menubar, address bar, etc.

wishmaster2
05-09-2007, 02:28 PM
thanks dude!!! done that!!!

Snee
05-09-2007, 03:57 PM
function loginWindow()
{
//Works in FF and IE, but not in IE-tabs through FF.
if(!logged)
{
//Creates a login window if the user isn't logged in.
//The new window calls the validator() function as th ok-button is clicked.
newWindow = window.open("", "newWindow", "height=100, width=220, toolbar=no, menubar=no");
newWindow.document.write("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2//EN'>");
newWindow.document.write("<html><head><title>Login</title><link rel='stylesheet' type='text/css' href='main.css' /></head><body>" +
"Username: <input class='outerInput' id='un' type='text' /><br />Password: <input class='outerInput' id='pw' type='password' />"
+ "<input class='activeField' type=submit value='OK' onclick='opener.validator();'></body></html>");
newWindow.document.close();
}
else
{
//Calls click() to set the internal page to the content div if the user i s logged in.
click("pages/internal.html", "", "html", "internal")
}
}

A function I wrote in an old project.

It generates a simple ~popup, if the user isn't logged in.

The function resided in an external .js, which I accessed with <script type="text/javascript" language="javascript" src="main.js"></script> between the <head>-tags.