Discussion Locked

javascript and resize windows

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have 2 question :
1- I want create an HTML page with javascript .
And I want when user resize window ,
I refresh page again How can I ?
2- I have an string variable in javascript I want to search in it and find some word.
I mean I want a function like INSTR in vbscript.
thanks

4 replies

by dem_

hi,

I will provide a solution to the first question.

The follow will resize the browser window to 600x600 and postion it in the center of the screen. You can replace 600 with any other value
or screen.availWidth and screen.availHeight to maximize the window.

self.resizeTo(600,600)
self.moveTo(((screen.availWidth-600)/2),((screen.availHeight-600)/2))

Next you can reload the document if the user resizes using the following:

if (document.all && document.resize) document.URL=location.href; // Microsoft IE

if (document.layers && window.resize) window.location.href = window.location.href; // Netscape

regards.

by dem_

hi,

I am not big on vbscript at this time but quite
familiar with Javascript. I believe I have a solution for the 2nd question.

To search for a string within a string or word. You can very well replace the "@" with a word or phrase.

This simple email validate function checks within a form input for the "@" symbol and responds with a valid/invalid message.

This should be place within the "script" tags.
function valid(obj)
{
if (obj.value.indexOf("@") != -1)
{
obj.value="valid input";
obj.focus();
return true;
}
else
{
obj.value="invalid input";
return false;
}
}

this should be placed within the BODY tags.

Hope this is what you are looking for.

regards

by eb_alavi

try this code for substring
function search(target,term,caseSens,wordOnly){
//target=targetSting , term=substring
// For example
// strA="Hi how are you";
// strB="ho";
// var check=search(strA,strB,0,0);
// if strb found check = true
var ind=0;
var next=0;
if (!caseSens){
term=term.toLowerCase();
target=target.toLowerCase();}
while ((ind=target.indexOf(term,next))>=0){
if (wordOnly) {
var befor=ind-1;
var after=ind+term.length;
if(!(space(target.charAt(before))&&space(target.charAt(after)))){
next=ind+term.length;
continue;}
}
return true;
}
return false;
}
function space(check){
var space=".,/<>?!`':;@#$%^&*()=-|[]{}"+'"'+"\\n\t";
for (var i=0;i

This discussion is closed to new replies.