PDA

Click to See Complete Forum and Search --> : [RESOLVED] Minimizing Javascript use


Nightwalker83
Dec 28th, 2009, 07:13 PM
Hi,

Is it a good idea to just use php wherever possible in a website instead of having to use javascript/ajax? Since most of the things I have done in javascript/ajax could be achieved just by using php I thought why not just get rid of the javascript/ajax altogether. What implications would there be if a website just used: html, css and php?

Thanks,


Nightwalker

kows
Dec 29th, 2009, 11:54 AM
I'm not entirely sure what you mean when you ask for what kind of implications there would be if a website just used HTML, CSS and PHP. that's all you need to make a website in the first place.

I'm of the mentality that your basic website is simply your HTML and CSS. and you only use PHP to produce and display content, so it's almost even irrelevant to this discussion. that's really all there is to it. after doing that, your website could be considered done.

javascript is something that enhances your website. this means that after your website is finished you can use javascript to add perks. whether it be dynamic/fluid functionality in the form of ajax, or whatever else, javascript is just something to use it enhance a website. at least, that's my take on it.

obviously, when you're that comfortable using javascript, the implementation can go hand in hand rather than finishing the static content (the basic website part) and then adding in the perks. until you're comfortable enough building a website with just HTML and CSS (with PHP for content -- irrelevant as mentioned before), I wouldn't really worry too much about using javascript (or even flash, in your case) in it. tackle one thing at a time.

unless you really know what you're doing, or you get a lot of help (since you are going to school), it is incredibly difficult to take on the task of mastering HTML, CSS, Flash, PHP and JavaScript all at once. I can tell that you're struggling to use each of them, so I would consider taking a step back and focusing on something instead.

SambaNeko
Dec 29th, 2009, 12:49 PM
Can't add much to what kows has already said. Your site is markup (HTML, with PHP used to generate it) and styling (CSS); Javascript is for embellishment.

Personally I never bothered with Javascript for the longest time because I found it unintuitive, verbose, and completely unnecessary. The first two complaints have been mitigated for me by both experience and jQuery (the former as a result of the latter), but it's still unnecessary. Thus I'd advise to "minimize JS use" to nothing - don't use it until you want to use it.

Nightwalker83
Dec 29th, 2009, 05:57 PM
javascript is something that enhances your website. this means that after your website is finished you can use javascript to add perks. whether it be dynamic/fluid functionality in the form of ajax, or whatever else, javascript is just something to use it enhance a website. at least, that's my take on it.


Yeah, I know it's just that I've seen things such as form validation and retrieving the last modified date done in both javascript and php. I was wondering what other things php could be used for that javascript/ajax would normally do?


Personally I never bothered with Javascript for the longest time because I found it unintuitive, verbose, and completely unnecessary. The first two complaints have been mitigated for me by both experience and jQuery (the former as a result of the latter), but it's still unnecessary. Thus I'd advise to "minimize JS use" to nothing - don't use it until you want to use it.


That is exactly what I was thinking! It appears there is little to no reason apart for cut and paste type needs to use javascript on a website. Although, that makes be wonder if there is a php alternative to javascript that flash uses to show buttons.

SambaNeko
Dec 29th, 2009, 08:53 PM
I was wondering what other things php could be used for that javascript/ajax would normally do?

You kind of have it backwards. :) The stuff that people do with JS (and AJAX by extension) is more "normally" done with just server side scripting; JS has just gotten pretty popular lately*, so people are adding flourishes to their pages.

*By which I mean useful, elegant Javascript as opposed to the stuff of the early 90s where every Geocities page had a "Enter name:", "Welcome, name!" alert pop-up, followed by no less than 3 scripting error warnings. Ah, those were the days...

Form validation, for example - you submit your form and do the validity checking with PHP. If something was wrong, you'd send the person back to the form page. Javascript is convenient here because it can check the form data without leaving the initial page that the form is on, whereas PHP needs to load at least one new page in this scenario. Obviously users appreciate convenience, but the point is that it's not necessary.

That's [usually] what Javascript is for: adding some functionality that's not necessary, but nice.

Although, that makes be wonder if there is a php alternative to javascript that flash uses to show buttons.

Not sure what you mean here...

Nightwalker83
Dec 29th, 2009, 11:36 PM
You kind of have it backwards. :)

I would have thought it be going from javascript which could be disabled from javascript which can be disable by the user to php which can not. That make more sense because if you have something on your site that is needed for some reason in-order for a form to send data to the server, wouldn't it be better if it remained functional so the data transfer always works?


Not sure what you mean here...

Flash uses javascript which it automatically creates to control the buttons on a website. However, since javascript can be disabled the buttons will disappear I was wondering if it possible to replace client-side functionality with server-side functionality so the buttons can't be disabled? Since ajax too is a client side language it too would be able to be disabled by the user.

So far the only way I am aware of to overcome this is to use normal hyperlinks to each page surround by noscript tags but that would just add to mess of the code f you need but noscript tags around every link on the page.

Jenner
Dec 30th, 2009, 08:34 AM
I would have thought it be going from javascript which could be disabled from javascript which can be disable by the user to php which can not.

I agree, I would have thought so too. Javascript can be a huge security liability while PHP which is entirely server-side is not. It's the number one tech of choice for phishing sites. I know plenty of large companies that run script-blockers.

SambaNeko
Dec 30th, 2009, 12:12 PM
I may have been misunderstood..? You were asking "what things PHP could do that normally JS would do," and I'm saying that, if you're looking at web development from a conventional standpoint, the question would be: "what could JS do that normally PHP would do?" Everything of a functional nature that can be done with JS, can be done with PHP (not vice-versa).

As for Flash, if you have a SWF that simply contains a button which goes to a URL on click, then there's no need for JS. And you can certainly still embed SWFs on a page without JS as well. But calling external JS functions from your SWF, would fail if JS is disabled, yes.

The ideal way to deal with your scenario - a set of link buttons in Flash that won't work without JS enabled - is to set up a div with your links in plain HTML, and then have JS replace the content of the div with your Flash. That way, if JS is disabled, the links that were originally in the div will remain visible, and if JS is enabled, they'll be replaced with your Flash content instead.

Also, as an aside: AJAX is not a language; it merely refers to a particular usage of Javascript.

dilettante
Dec 30th, 2009, 05:11 PM
The interesting thing about AJAX (or Ajax) is that it is a 2005 term for something we were using extensively in-house for intranet applications in IE as early as 1996. Until around 2002 or so other browsers didn't offer the facilities supplied with IE, and even now the most common cloned component is the XmlHttpRequest object.

By around 1998 there was a standard Microsoft-supplied Java applet for doing postbacks that was fairly browser-neutral but it's long dead now.

Most of this comes down to DHTML in the browser that interacts with the host using out of band postbacks instead of additional full-page round-tripping.

We also did almost all of this using VBScript in the browser instead of JScript, since it offered cleaner support for scripting the event model in IE and we didn't have to support 2nd class browsers for intranet applications anyway. This gave us things like paging through databases (viewed in data-bound IE <TABLE>s), ActiveX charting objects that could be refreshed, filtered, etc. dynamically, and tons of other interactions that didn't require a new page-fetch from the server.

In the end it wasn't worthwhile though. People who could do both server-side and client-side Web development were hard to come by and hard to retain. Too many of the six week wonder "Web developers" we were able to hire just didn't have very strong programming skills and client/server development comprehension.

Today you have frameworks that can help dumb down the skill level needed though. Javascript-based client-side frameworks seem to be a dime a dozen now, though few do a good job of integrating well with server-side IDEs. That's why we got WebClasses in VB6 which morphed into ASP.Net WebForms later on, as well as things like Ruby on Rails.

Many former PHP hackers have moved to Rails and are very happy there.

Nightwalker83
Dec 30th, 2009, 07:26 PM
I may have been misunderstood..? You were asking "what things PHP could do that normally JS would do," and I'm saying that, if you're looking at web development from a conventional standpoint, the question would be: "what could JS do that normally PHP would do?" Everything of a functional nature that can be done with JS, can be done with PHP (not vice-versa).


Sorry, I think I wrote it around the wrong way in my original post.


As for Flash, if you have a SWF that simply contains a button which goes to a URL on click, then there's no need for JS. And you can certainly still embed SWFs on a page without JS as well. But calling external JS functions from your SWF, would fail if JS is disabled, yes.


You are wrong there! Javascript for some reason is used by flash to show the buttons on the page amongst other things. I don't know why they included the use of javascript this way because it doesn't appear to be needed.

Edit:

CS2:

See CS3!

CS3:

The following is put in an external *.js file upon publishing the flash file.


//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved.
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
var version;
var axo;
var e;

// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

try {
// version will be set for 7.X or greater players
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
version = axo.GetVariable("$version");
} catch (e) {
}

if (!version)
{
try {
// version will be set for 6.X players only
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");

// installed player is some revision of 6.0
// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
// so we have to be careful.

// default to the first public version
version = "WIN 6,0,21,0";

// throws if AllowScripAccess does not exist (introduced in 6.0r47)
axo.AllowScriptAccess = "always";

// safe to call for 6.0r47 or greater
version = axo.GetVariable("$version");

} catch (e) {
}
}

if (!version)
{
try {
// version will be set for 4.X or 5.X player
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = axo.GetVariable("$version");
} catch (e) {
}
}

if (!version)
{
try {
// version will be set for 3.X player
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
version = "WIN 3,0,18,0";
} catch (e) {
}
}

if (!version)
{
try {
// version will be set for 2.X player
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
version = "WIN 2,0,0,11";
} catch (e) {
version = -1;
}
}

return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
// NS/Opera version >= 3 check for Flash plugin in plugin array
var flashVer = -1;

if (navigator.plugins != null && navigator.plugins.length > 0) {
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
var descArray = flashDescription.split(" ");
var tempArrayMajor = descArray[2].split(".");
var versionMajor = tempArrayMajor[0];
var versionMinor = tempArrayMajor[1];
var versionRevision = descArray[3];
if (versionRevision == "") {
versionRevision = descArray[4];
}
if (versionRevision[0] == "d") {
versionRevision = versionRevision.substring(1);
} else if (versionRevision[0] == "r") {
versionRevision = versionRevision.substring(1);
if (versionRevision.indexOf("d") > 0) {
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
}
}
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
}
}
// MSN/WebTV 2.6 supports Flash 4
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
// WebTV 2.5 supports Flash 3
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
// older WebTV supports Flash 2
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
else if ( isIE && isWin && !isOpera ) {
flashVer = ControlVersion();
}
return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
versionStr = GetSwfVer();
if (versionStr == -1 ) {
return false;
} else if (versionStr != 0) {
if(isIE && isWin && !isOpera) {
// Given "WIN 2,0,0,11"
tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
tempString = tempArray[1]; // "2,0,0,11"
versionArray = tempString.split(","); // ['2', '0', '0', '11']
} else {
versionArray = versionStr.split(".");
}
var versionMajor = versionArray[0];
var versionMinor = versionArray[1];
var versionRevision = versionArray[2];

// is the major.revision >= requested major.revision AND the minor version >= requested minor
if (versionMajor > parseFloat(reqMajorVer)) {
return true;
} else if (versionMajor == parseFloat(reqMajorVer)) {
if (versionMinor > parseFloat(reqMinorVer))
return true;
else if (versionMinor == parseFloat(reqMinorVer)) {
if (versionRevision >= parseFloat(reqRevision))
return true;
}
}
return false;
}
}

function AC_AddExtension(src, ext)
{
if (src.indexOf('?') != -1)
return src.replace(/\?/, ext+'?');
else
return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs)
{
var str = '';
if (isIE && isWin && !isOpera)
{
str += '<object ';
for (var i in objAttrs)
{
str += i + '="' + objAttrs[i] + '" ';
}
str += '>';
for (var i in params)
{
str += '<param name="' + i + '" value="' + params[i] + '" /> ';
}
str += '</object>';
}
else
{
str += '<embed ';
for (var i in embedAttrs)
{
str += i + '="' + embedAttrs[i] + '" ';
}
str += '> </embed>';
}

document.write(str);
}

function AC_FL_RunContent(){
var ret =
AC_GetArgs
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
, "application/x-shockwave-flash"
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
var ret =
AC_GetArgs
( arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
, null
);
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
var ret = new Object();
ret.embedAttrs = new Object();
ret.params = new Object();
ret.objAttrs = new Object();
for (var i=0; i < args.length; i=i+2){
var currArg = args[i].toLowerCase();

switch (currArg){
case "classid":
break;
case "pluginspage":
ret.embedAttrs[args[i]] = args[i+1];
break;
case "src":
case "movie":
args[i+1] = AC_AddExtension(args[i+1], ext);
ret.embedAttrs["src"] = args[i+1];
ret.params[srcParamName] = args[i+1];
break;
case "onafterupdate":
case "onbeforeupdate":
case "onblur":
case "oncellchange":
case "onclick":
case "ondblclick":
case "ondrag":
case "ondragend":
case "ondragenter":
case "ondragleave":
case "ondragover":
case "ondrop":
case "onfinish":
case "onfocus":
case "onhelp":
case "onmousedown":
case "onmouseup":
case "onmouseover":
case "onmousemove":
case "onmouseout":
case "onkeypress":
case "onkeydown":
case "onkeyup":
case "onload":
case "onlosecapture":
case "onpropertychange":
case "onreadystatechange":
case "onrowsdelete":
case "onrowenter":
case "onrowexit":
case "onrowsinserted":
case "onstart":
case "onscroll":
case "onbeforeeditfocus":
case "onactivate":
case "onbeforedeactivate":
case "ondeactivate":
case "type":
case "codebase":
case "id":
ret.objAttrs[args[i]] = args[i+1];
break;
case "width":
case "height":
case "align":
case "vspace":
case "hspace":
case "class":
case "title":
case "accesskey":
case "name":
case "tabindex":
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
break;
default:
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
}
}
ret.objAttrs["classid"] = classid;
if (mimeType) ret.embedAttrs["type"] = mimeType;
return ret;
}


CS4:

This javascript code is put in the published html file:


It appears that the only reason that javascript is needed by flash is for the different versions of flash player.


The ideal way to deal with your scenario - a set of link buttons in Flash that won't work without JS enabled - is to set up a div with your links in plain HTML, and then have JS replace the content of the div with your Flash. That way, if JS is disabled, the links that were originally in the div will remain visible, and if JS is enabled, they'll be replaced with your Flash content instead.


Yes, that is how I have been designing the navigation for my site where I use flash.

SambaNeko
Dec 31st, 2009, 08:34 PM
Yes, I know that Flash includes Javascript to embed its SWF files when you publish through the IDE. But this JS is absolutely not necessary for embedding - you can embed with nothing more than <embed> and <object> tags. I believe the reason Flash started using the JS embed method was because of a certain lawsuit (http://en.wikipedia.org/wiki/Eolas) whereby SWFs had to have obnoxious "click to activate" messages in IE, and JS circumvented this.

Nightwalker83
Dec 31st, 2009, 10:37 PM
Yes, I know that Flash includes Javascript to embed its SWF files when you publish through the IDE. But this JS is absolutely not necessary for embedding - you can embed with nothing more than <embed> and <object> tags. I believe the reason Flash started using the JS embed method was because of a certain lawsuit (http://en.wikipedia.org/wiki/Eolas) whereby SWFs had to have obnoxious "click to activate" messages in IE, and JS circumvented this.

I'm not talking about the <embed> tags! I know they should be replaced by <object> tags. However, yes, I agree with you that the javascript for flash really isn't needed. Thanks, for the link!

This section of javascript sends the info from the movie to the player:


<script language="JavaScript" type="text/javascript">
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0',
'width', '550',
'height', '400',
'src', 'Untitled-1',
'quality', 'high',
'pluginspage', 'http://www.adobe.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'Untitled-1',
'bgcolor', '#ffffff',
'name', 'Untitled-1',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'Untitled-1',
'salign', ''
); //end AC code
</script>


If you remove either this code or the code in post #10 the movie will not longer display.

kows
Jan 1st, 2010, 12:05 AM
As Samba said, the JavaScript you provided there to embed Flash is completely unnecessary... meaning, JavaScript has nothing to do with Flash and is not required to embed Flash within a page. JavaScript is not the method I would ever suggest one would use to embed Flash, either.

The AC_FL_RunContent() JavaScript function is something that exists solely to create the HTML mark-up required to display Flash content without actually putting the mark-up in the HTML. I tried to explain this to you a little previously (in another thread), but generally it seems you skim through posts without getting too much from them...

As Samba mentioned, this function was originally created by Adobe for their Flash publishing software to get around the "Click to activate" thing in IE. Because the page did not actually have an <object> that was created at run-time, and instead had an <object> that was created after run-time via JavaScript, it circumvented the "feature" added to IE. This "feature" has since been removed, but you can read all about this function here (http://www.adobe.com/devnet/activecontent/articles/devletter.html) if you'd like.

Another reason one might use this JavaScript function nowadays is for validation. The original way of embedding Flash files using the <embed> tag doesn't validate. This is because the <embed> tag was never a part of any HTML standard. To get the code to validate, however, only the following mark-up is required:

<object type="application/x-shockwave-flash" data="path/to/file.swf" width="X" height="Y">
<param name="movie" value="path/to/file.swf" />
</object>

This does produce a flaw when loading Flash SWF files in IE, though. IE needs to completely load any <object> files before displaying them when you use this code, while other browsers will stream them while they're loading. This isn't an issue for most Flash files (most Flash files are generally small), but will produce a problem for anything large. There is a workaround, and you can also read more about this method of embedding Flash and the workaround itself here (http://www.alistapart.com/articles/flashsatay).

Nightwalker83
Jan 1st, 2010, 01:47 AM
Another reason one might use this JavaScript function nowadays is for validation. The original way of embedding Flash files using the <embed> tag doesn't validate. This is because the <embed> tag was never a part of any HTML standard. To get the code to validate, however, only the following mark-up is required:

<object type="application/x-shockwave-flash" data="path/to/file.swf" width="X" height="Y">
<param name="movie" value="path/to/file.swf" />
</object>


I managed to get the flash to show without needing to use annoying javascript using this code:


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled-1</title>
</head>
<body bgcolor="#ffffff">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="400">
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="Untitled-1.swf" width="550" height="400">
<!--<![endif]-->
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</body>
</html>

Pradeep1210
Jan 1st, 2010, 02:28 AM
Is it a good idea to just use php wherever possible in a website instead of having to use javascript/ajax? Since most of the things I have done in javascript/ajax could be achieved just by using php I thought why not just get rid of the javascript/ajax altogether. What implications would there be if a website just used: html, css and php?

Each has its own role to play, and you should make full use of both.

Use javascript for simple tasks that don't have any security risk but spice up the user browsing experience. e.g. appearence related things, etc. Always put fallback code too. Never assume that your javascript code will always succeed, as you have no control over it.
Use PHP or other server side code to do heavy processing or database related tasks etc.

If you try to substitute one for the other you would be messing up things.
e.g. assume the situation, you want to show backcolor of textbox yellow when empty and white when filled. Ideally you should use javascript for this. If you use server-side code, you would be posting back to the server on each keystroke and making the server process the whole page again and again unnecessarily, where javascript would have done very well.
So first segregate the tasks. See what can be done on on the client browser and what can't be done. However never rely faithfully on the client browser.

kows
Jan 1st, 2010, 02:31 AM
I managed to get the flash to show without needing to use annoying javascript using this code:


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled-1</title>
</head>
<body bgcolor="#ffffff">
<object id="FlashID" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="400">
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="Untitled-1.swf" width="550" height="400">
<!--<![endif]-->
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</body>
</html>


... except that won't load anything in IE. you need to have the <param> tag present with the 'movie' attribute defined to let IE know what is being loaded; otherwise, you're telling it you have an object to load and then you never get around to telling it what to put inside of that object.

you should simply use the code I've posted above if you want the most simplistic way of loading a Flash file and care about validation. if you don't really care about validation, why are you even doing any of this? do it the old fashioned way. when you publish a flash file, the raw <object> stuff is all defined within the <noscript> stuff.

Nightwalker83
Jan 1st, 2010, 03:22 AM
... except that won't load anything in IE. you need to have the <param> tag present with the 'movie' attribute defined to let IE know what is being loaded; otherwise, you're telling it you have an object to load and then you never get around to telling it what to put inside of that object.



<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,0,0" width="550" height="400" id="Untitled-1" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="Untitled-1.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" />
</object>
</noscript>


Looking at that code you there is no javascript involved if whoever need to include the javascript code in browser for whatever reason it was why don't Microsoft, etc just include the javascript code in their browsers?

why are you even doing any of this?

To see if it is possible to do create websites like I have been doing except without using javascript.

Each has its own role to play, and you should make full use of both.

Use javascript for simple tasks that don't have any security risk but spice up the user browsing experience. e.g. appearence related things, etc. Always put fallback code too. Never assume that your javascript code will always succeed, as you have no control over it.
Use PHP or other server side code to do heavy processing or database related tasks etc.


I agree! However, as stated above I have seen instances where javascript would be used for things such as form validation.

Pradeep1210
Jan 1st, 2010, 06:21 AM
I agree! However, as stated above I have seen instances where javascript would be used for things such as form validation.
Just as I said, don't trust or rely on javascript. Use it just as an extra feature. If it is there, it's good for you and your client. If it is not, you didn't plan to use it anyways.

Javascript validation still makes sense. That's because if it is not there, for each mistake the user makes and tries to submit, your server will return back error to the browser. So it is more work for the browser, your network, as well as your server. If the javascript validation is there, you would avoid many round trips to the server. Don't think of it in terms of one single web browser; but instead the overall load on your server with all web-browsers requesting the same page again and again, which you could have controlled to a large extent using javascript validation.

But don't trust that the javascript validated values you would get on the server will always be correct. That's because it is possible to bypass your javascript code all together, or even send you absurd/spoofed values, which can then have security implications too. Always validate using server-side code before inserting anything in the database, or taking any action based on data submitted to you from client side.

Nightwalker83
Jan 3rd, 2010, 08:30 PM
Yeah, I just going to keep the link to the javascript file in my site even though I may not need to use javascript. It would save me having to edit the pages later if I need to include javascript on my site.