Varshyl Blog

Web Simplified….

Archive for the ‘Fun with Javascript’ Category

Fun javascript

just copy and paste below codes in browser url address bar, hit go button or enter and see the fun


javascript:R=-1;DI=document.links;DIL=DI.length;function A(a,b,c){return Math.sin(R/350*6.28*b+a)*c+c}function B(a){DIS=DI.item(a).style;DIS.position=’absolute’;DIS.left=A(5,100,500);DIS.top=A(5.6,60,150)}setInterval(’R++;B(R%DIL)’,15);void(0)

- shashi arya

Only by loading a framset with all four pages loaded - with the onLoad event handler in the frameset using the window print method to print each frame:
[form]
[input type=”button” onClick=”if (window.print) location.href=’printframeset.htm’”]
[/form]
And then in printframeset.htm:
[html]
[head]
[script language=”JavaScript”][!–
function printAll() {
for (var i=0;i[frames.length;i++)
if (window.print)
frames[i].print();
}
//–][/script]
[/head]
[frameset onLoad=”printAll()” rows=”*,*,*”]
[frame xsrc=”apage.htm” mce_src=”apage.htm” ]
[frame xsrc=”anotherpage.htm” mce_src=”anotherpage.htm” ]
[frame xsrc=”yetanotherpage.htm” mce_src=”yetanotherpage.htm” ]
[/frameset]
[/html]
The previous script has been reported not to work on some platforms (it works perfectly on Netscape Navigator 4.7 on Linux). I assume on some platforms only one print dialogue box at a time can be opened. It might be possible to overcome this with a setTimout, but its going to be difficult to know when to start another one. A set delay of, say, 5 seconds might be too short if the user doesn’t hit the print button. Anyway try:
[html]
[head]
[script language=”JavaScript”][!–
function printAll() {
for (var i=0;i[frames.length;i++)
if (window.print)
setTimeout(’frames[’ + i + ‘].print()’,5000 * i);
}
//–][/script]
[/head]
[frameset onLoad=”printAll()” rows=”*,*,*”]
[frame xsrc=”apage.htm” mce_src=”apage.htm” ]
[frame xsrc=”anotherpage.htm” mce_src=”anotherpage.htm” ]
[frame xsrc=”yetanotherpage.htm” mce_src=”yetanotherpage.htm” ]
[/frameset]
[/html]

Note; Repleace[ .] with <,> in code

Hi All,

I am back with more tips and tricks of Javascript, to make it “fun with Javascript” . Contrary to common layman notion that javascript is not user friendly or not very reliable, it is very reliable and user friendly. Sample this even google and Yahoo use them in there application, this shows the reliabilty and flexibilty Javascript offer.

Today I shall discuss “how can we call Javascript function from PHP code without any click event happening on our page”

Here is sample code:

Write you Javascript function in HEAD

/HEAD/
/SCRIPT LANGUAGE=”javascript”/
function ProcA () {
alert (”message”);
}
//SCRIPT/
//Head/

Calling this function from PHP code -for instance based on a decision.

if ($decision==’true’) {
echo “/SCRIPT LANGUAGE=”javascript”/”;
echo “FunctionA;n”;
echo “//SCRIPT/
}
?>

P.S- repleace / with < or > whereever applicable.

Code End here///////////////////

That simple noooooooo:)

If you have any question/queries. Contact us at www.varshyltech.com

Hi All,

Today I will talk about how can we call two javascript function on one button click.

I have seen many case while doing website designing that many times we get situation where we want to check/validate couple of things on one button click, contrary to general notion people have it is very much possible and very easy. It is same way we call single function , except a ‘;’ between two function we want to call on button click.

Following sample code will give you an example: here two function are called on ‘Submit’ button clik.
input type=”button” value=”Submit” onClick=”function1(parameter1);function1(parameter1)”

////end here

this is it! simple and short:)

-Harish Sharma

Varshyl Tech

JavaScript Validation: Script to validate input value is an Integer.

We will use Regular Expression and exec() function to do the validation.

Sample Code:

//Code for Form which captures click event and calls ‘validate()’ function.

//function validate()

// {

//frm = document.form

//var freg = /(^\d\d*$)/;

// var Intval = frm.text.value;

//if(!fr.exec(Intval))

// {

// alert(”Only Integer Value allowed”);

// return false;

// }

// }

——————————————-

Code Explanation:
Create a Regular Expression variable
var freg = /(^\d\d*$)/;

Use exec function to see if it matches regular expression – if it return ‘False’ show the message and return false.
if(!fr.exec(Intval))

That’s it. Hope this help you guys:-)

Advertisement: Varshyl Tech offers website designing, logo designing, Search engine promotion, custom software development solutions.