haukke45
03-20-2009, 08:41 AM
Hello,
I'm back with probably another simple answer to my dilerious question/problem :lol:
I'm looking for a javascript that tell the difference between refresh and exit. If a person refreshes the web page I want that page to just refresh but if the person types in a address and clicks go to another webpage , or clicks on a <a href="/" target="self">, or just closes the window/tab on there browser it would use an exit window.open(href).
This is the only exit script i know:
<script language="JavaScript">
<!--//
var exit=true;
function bye(){
if (exit) {
window.open("http://www.htmlforums.com/");
}}
// -->
</script>
Simple but if I refresh the page it thinks it is exiting and popups the other webpage. Why would I want to refresh you say. Well my webpage is simple html with a thumbnail view and gal href script like this:
<script language=javascript>
//
var path_to_gal='http://www.htmlforums.com/gal/';
var path_to_thumb='http://www.htmlforums.com/thumbs/';
var num_of_thumb=100;
thumbs = new Array(num_of_thumb);
function gen(n){return (parseInt(Math.random()*n)+1);}
function check_num(num){
for (j=0;j<num_of_thumb;j++){if (thumbs[j]==num) return false};
return true;}
ex=gen(num_of_thumb);
for (k=0;k<num_of_thumb;k++){
if (check_num(ex)) {thumbs[k]=ex;}
else {while (!check_num(ex)) {ex=gen(num_of_thumb)};
thumbs[k]=ex;}}
var t=0;
function thumb_view(){
document.writeln('<IMG SRC="'+path_to_thumb+thumbs[t]+'.jpg" onclick="gal_view(this);" border="0" alt="Check This HtmlForums Gallery Out!!">');
t++;}
function gal_view(par){window.open(path_to_gal+thumbs[par-1]+'.html','','');}
//
</script>
<body>
<td width="100" hieght="100" align="center" valign="top">
<script language=javascript>thumb_view()</script><br><b>1st gallery</b></a></td>
<body>
This way I can have only a few thumbnails on the webpage and when they click on my "more button" it refreshes with different thumbnails (and hrefs). helps keep the paper-use (used drive space) to a minimum. But my issue is I have other links on the page that leave my page to a different part of the site forgo "the exit bit" and there is the delimma everytime I refresh it thinks it is exiting.
can someoe help please? :confused:
.
I'm back with probably another simple answer to my dilerious question/problem :lol:
I'm looking for a javascript that tell the difference between refresh and exit. If a person refreshes the web page I want that page to just refresh but if the person types in a address and clicks go to another webpage , or clicks on a <a href="/" target="self">, or just closes the window/tab on there browser it would use an exit window.open(href).
This is the only exit script i know:
<script language="JavaScript">
<!--//
var exit=true;
function bye(){
if (exit) {
window.open("http://www.htmlforums.com/");
}}
// -->
</script>
Simple but if I refresh the page it thinks it is exiting and popups the other webpage. Why would I want to refresh you say. Well my webpage is simple html with a thumbnail view and gal href script like this:
<script language=javascript>
//
var path_to_gal='http://www.htmlforums.com/gal/';
var path_to_thumb='http://www.htmlforums.com/thumbs/';
var num_of_thumb=100;
thumbs = new Array(num_of_thumb);
function gen(n){return (parseInt(Math.random()*n)+1);}
function check_num(num){
for (j=0;j<num_of_thumb;j++){if (thumbs[j]==num) return false};
return true;}
ex=gen(num_of_thumb);
for (k=0;k<num_of_thumb;k++){
if (check_num(ex)) {thumbs[k]=ex;}
else {while (!check_num(ex)) {ex=gen(num_of_thumb)};
thumbs[k]=ex;}}
var t=0;
function thumb_view(){
document.writeln('<IMG SRC="'+path_to_thumb+thumbs[t]+'.jpg" onclick="gal_view(this);" border="0" alt="Check This HtmlForums Gallery Out!!">');
t++;}
function gal_view(par){window.open(path_to_gal+thumbs[par-1]+'.html','','');}
//
</script>
<body>
<td width="100" hieght="100" align="center" valign="top">
<script language=javascript>thumb_view()</script><br><b>1st gallery</b></a></td>
<body>
This way I can have only a few thumbnails on the webpage and when they click on my "more button" it refreshes with different thumbnails (and hrefs). helps keep the paper-use (used drive space) to a minimum. But my issue is I have other links on the page that leave my page to a different part of the site forgo "the exit bit" and there is the delimma everytime I refresh it thinks it is exiting.
can someoe help please? :confused:
.