Web Development

Our forums are currently in maintenance mode and the ability to post is disabled. We will be back up and running as soon as possible. Thanks for your patience!

General discussion


javascript and resize windows

By eb_alavi ·
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.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Comments

Collapse -

by dem_ In reply to javascript and resize win ...


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.


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


Collapse -

by dem_ In reply to javascript and resize win ...


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";
return true;
obj.value="invalid input";
return false;

this should be placed within the BODY tags.
<input type="text" name="email" value="" onchange="valid(this)">

Hope this is what you are looking for.


Collapse -

by eb_alavi In reply to

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){
while ((ind=target.indexOf(term,next))>=0){
if (wordOnly) {
var befor=ind-1;
var after=ind+term.length;
return true;
return false;
function space(check){
var space=".,/<>?!`':;@#$%^&*()=-|[]{}"+'"'+"\\n\t";
for (var i=0;i<space.length;i++)
if (check==space.charAt(i)){return true;}
if (check=="") {return true;}
if (check==null){return true;}
return false;

function runMenu(strURL){
var a=search(strURL,"totalcompanies",0,0);
if (a) { //Do something }

Collapse -

by eb_alavi In reply to javascript and resize win ...

This question was closed by the author

Related Discussions

Related Forums