0

I am building a rotating page. For URLs. The problem is that the page does not reload a different URL when you refresh the page, and I want it to load a different URL when someone enters the site. I have tried different coding and nothing seems to work. Here is the code.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content=
"text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array(0);
 
      page[ 0 ] = "http://www.homebiz.usaloe.com";

      page[ 1 ] = "http://www.makethatmoney.usaloe.com";

      page[ 2 ] = "";

      page[ 3 ] = "";

      page[ 4 ] = "";
     
      page[ 5 ] = "";

      page[ 6 ] = "";

      page[ 7 ] = "";

      var next_page = function() {

      page_index = (( page_index === 8 ) ? 0 : page_index );

      if ( typeof Win !== "undefined" ) {

      Win.location.href = page[ page_index ];

      } ++page_index;

      };

      

      window.onload = function() {

      Win = window.open( page[ 0 ], 'Win', 'resize=yes,toolbar=yes, status=yes,scrollbars=yes, screenX=0,screenY=0, width=1000, height=666' );

      timer = setInterval( "next_page()", 10000000 );

      };

      

      // -->

</script>
</head>
<body>
</body>
</html>
5
Contributors
13
Replies
15
Views
7 Years
Discussion Span
Last Post by hielo
Featured Replies
  • 1

    Pop up marketing is about as unfriendly as it gets, which is why most users have a pop-up blocker installed. This is not the way to go either for you or your visitors. I think you should find a more more modern way to do it. [B]Airshow[/B] Read More

  • 1

    [quote]The problem is that the page does not reload a different URL when you refresh the page[/quote] that's because on every reload, the code executes again from the top, like it is the very first time it is executing. You need to "maintain" state across refreshes. For this you will … Read More

  • 1

    On my previous post change line 53: [icode]if(!page_index)[/icode] to: [icode]if(null===page_index)[/icode] if you are having difficulty figuring out the path to your cookie.js file, then try typing the full path in the browser's address bar - ex: [url]http://www.yoursite.com/scripts/cookies.js[/url] If you see the browser trying to download the js file OR if … Read More

  • 1

    [QUOTE]how to keep it from being a pop up? [/QUOTE] For that, you should NOT be using window.open(). Instead, just assign the url to location.href: [CODE] <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> <title>Rotate Marketing</title> <!-- IMPORTANT: Notice that I am importing … Read More

1

Pop up marketing is about as unfriendly as it gets, which is why most users have a pop-up blocker installed.

This is not the way to go either for you or your visitors. I think you should find a more more modern way to do it.

Airshow

0

Pop up marketing is about as unfriendly as it gets, which is why most users have a pop-up blocker installed.

This is not the way to go either for you or your visitors. I think you should find a more more modern way to do it.

Airshow

The pop up will be gone I have that figured out. I just cannot figure out how to get the repeat to no continue to run through the other web pages, and how to get a different website to load on page refresh. That is what I am asking for help with.

0

Can you assist me with what I need to put in the code to make it do what I want or not?

1

The problem is that the page does not reload a different URL when you refresh the page

that's because on every reload, the code executes again from the top, like it is the very first time it is executing. You need to "maintain" state across refreshes. For this you will need to use cookies.

Refer to the code below. Pay special attention to the HTML comment that starts with IMPORTANT...

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		Win.location.href = page[ page_index ];
			createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 }
	 createCookie("lastPage",page_index,30);
      Win = window.open( page[ page_index ], 'Win', 'resize=yes,toolbar=yes, status=yes,scrollbars=yes, screenX=0,screenY=0, width=1000, height=666' );

      timer = setInterval( "next_page()", 10000000 );

      };

      

      // -->

</script>
</head>
<body>
</body>
</html>
Votes + Comments
Great bit of help. Thank you
0

please try
This (typeof Win !== undefined) instead of
( typeof Win !== "undefined")

I am not sure about it, just try.

Jino

0

Set some cookie first time , check the cookie and do not pop up next time.

Can you give me a example please? I tried following what the other person told me, and I am not able to get the link for some reason. Meaning that when I save the cookie as cookie.js I cannot get the JavaScript to recognize what is going on. So my screen shows blank.

1

On my previous post change line 53: if(!page_index) to: if(null===page_index) if you are having difficulty figuring out the path to your cookie.js file, then try typing the full path in the browser's address bar - ex:
http://www.yoursite.com/scripts/cookies.js

If you see the browser trying to download the js file OR if the browser shows you the content of cookies.js, then that IS the correct path. Once you figure out what is that full path, then use that full path as the src attribute of the script tag.

0

On my previous post change line 53: if(!page_index) to: if(null===page_index) if you are having difficulty figuring out the path to your cookie.js file, then try typing the full path in the browser's address bar - ex:
http://www.yoursite.com/scripts/cookies.js

If you see the browser trying to download the js file OR if the browser shows you the content of cookies.js, then that IS the correct path. Once you figure out what is that full path, then use that full path as the src attribute of the script tag.

Great that works. Now can you tell me how to keep it from being a pop up? I thought I had the coding correct but it keeps being a pop up I have tried to set the target to "_self" "_parent" "" "_blank" "_top" nothing is working

1

how to keep it from being a pop up?

For that, you should NOT be using window.open(). Instead, just assign the url to location.href:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<title>Rotate Marketing</title>

<!-- 
IMPORTANT: Notice that I am importing "cookies.js". Go to:
http://www.quirksmode.org/js/cookies.html

scroll down to the section titled "The Scripts" and grab those three functions.
save them to a file named cookies.js and import them into your page similarly to
the way I am doing below
 -->
<script src="cookies.js" type="text/javascript"></script>

<script type="text/javascript">

      <!--
 
      var Win;

      var page_index = 0;

      var page = new Array();
      page[ page.length ] = "http://www.homebiz.usaloe.com";
      page[ page.length ] = "http://www.makethatmoney.usaloe.com";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";
      page[ page.length ] = "";

      var next_page = function(){

      	//page_index = (( page_index === 8 ) ? 0 : page_index );
		page_index=++page_index % page.length;
      	if ( typeof Win !== "undefined" ) {

      		/* Win.location.href = page[ page_index ]; */
		location.href=page[ page_index ];
		createCookie("lastPage",page_index,30);
      	}
		

      };

      

      window.onload = function() {
	 page_index=readCookie("lastPage");
	 if(!page_index)
	 {
	 	page_index=0;
	 }
	 else
	 {
	 	page_index=++page_index % page.length;
	 }
	 createCookie("lastPage",page_index,30);
      	/* Win = window.open( page[ page_index ], 'Win', 'resize=yes,toolbar=yes, status=yes,scrollbars=yes, screenX=0,screenY=0, width=1000, height=666' ); */
	location.href=page[ page_index ];

      timer = setInterval( "next_page()", 10000000 );

      };

      

      // -->

</script>
</head>
<body>
</body>
</html>
0

Thank you so much. I appreciate what you have taught me and helped me fix. That is GREAT.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.