Jump to content
  • Announcements

    • boen_robot

      Guidelines and Netiquette   03/28/2017

      Posting Problems:   Having problems posting your topic? Read through this: To join, you agree to our terms and conditions and fill out and submit a registration form. An activation email will be sent to your email adress, so you'll need to verify your account. After that the account has to be validated by one of the moderators. This will mean that it can take up to a day to be activated. A couple of things to remember to ensure approval: Don't use an email address in one of those $2 four character .com domains eg. xyds.com. These will be deleted and the domain added to the banned list. Don't use an email address that is within a domain with a bad reputation for spam. A Google search is run on every email address and email domain. Don't sign up with an email address that doesn't exist, doesn't work or requires the sender to answer a quiz before their email can get to you. Put your country and or state and city in the signup form. Blank forms will go to the botton of the "to do" list. And make sure that your email address and your country match, saying you're from Alabama and using a .ru email address is not going to get you activated. After a membership is activated the first few posts will be monitored. Posting spam or unapproved topics described in the agreement results in an immediate ban. The email provider and the IP addresses associated with the account will be banned and all posts will be deleted. These strict measures have been deemed necessary to hinder spam. Sorry for any inconvenience this causes, but it's not liable to change. If, after reading this, you still can't post and don't understand why, contact one of the Moderators listed here.   Topic Guidelines   Including the following information can expedite an accurate response from board members: Must be a Specific Problem or Question related to web design and development Include Code in Question (wrap with   for small blocks of code and for longer blocks   ) Include Code Author Include Extra Notes/Modifications/Attempts Include web link to page/file when possible Content Guidelines   You may not post, upload, link to, or email any Content that contains, promotes, gives instruction about, or provides prohibited Content. Prohibited Content includes any Content that breaks any local, state, county, national or international law. Prohibited Content also includes: No direct or indirect advertising or websites, forums, products, services No hijacking of posts (do not post your question in someone elses) Content that infringes upon any rights [ex. MP3s and ROMs] (including, but not limited to, copyrights and trademarks) Abusive, threatening, defamatory, racist, or obscene Viruses or any other harmful computer software False Information or libel Spam, chain letters, or Pyramid schemes Gambling or Illicit drugs Terrorism Hacking or cheating for internet/online games Warez, Roms, CD-Keys, Cracks, Passwords, or Serial Numbers Pornography, nudity, or sexual material of any kind Excessive profanity Invasive of privacy or impersonation of any person/entity Hacking materials or information Posting Tips   There are more BBcodes than there are buttons for on the reply menu. To get the full list, click "BB Code Help" underneath the clickable smilie face menu. Use   for small snippets of code Use   for lengthy snippets of code Use   if your snippet is HTML (optional) Use   if your snippet is SQL (optional) Rules of Conduct   Be nice. There's no need for calling someone stupid if they ask an 'easy' question. Keep your avatars and signatures absolutely child friendly. We have a younger audience on this forum. Keep your language appropriate for the same reason above. Do not PM moderators for help on the forum. Post on the topic, or create a new one.   Spam:   Recently, as you have all without doubt noticed, we have had lots of spam and advertisement on the forum. Therefore, we'd like to alert you as to what to do when you have found any of the aforementioned annoying messages: it. Immediately. Give a clear reason, please, if the advertising is not evident. DO NOT POST! Report, let the post stay as is, and we will get to it, meanwhile if you continue to post as normal in the other threads, it won't be on the top so long. Refrain from PMing the member. This won't help at all, as they are most likely spambots anyway. Thank you.       Images in signatures:   After thinking of users on dial-up, we have decided to enforce the following rules regarding signatures. Please pay heed to them. Respecting these rules is respecting the members on this forum with dial-up. Signature rules: No animated images AT ALL. No matter the amount of animation. Maximum image widthxheight: 300x150 Maximum image (file) size: 15kb Use calm colors. Do not use highly contrasting images in your signature, as this can get really annoying when seeing several posts from one member in the same thread. The same prohibited content goes for images as for posts. Lastly, use common sense. No lengthy signatures please. Save us some scrolling. Thank you.       Links in signatures:   Please understand that w3schools.com only exists because of voluntary work and is barely supported by the advertising littered throughout the tutorials and the forum. So, please, stop advertising other sites. DO not post links that drive traffic away from the w3schools domain - especially to a site that offers similar if not identical information. Please help support the site by keeping individuals on it. Thank you. Here are some guidelines as to what you can put in your signature: w3schools links --> allowed w3.org links --> allowed browser links --> allowed html editor links --> allowed personal sites --> allowed tutorial sites competing with w3schools --> NOT allowed sites completely irrelevant to webprogramming and this forum --> NOT allowed   Thanks for understanding, and for taking the time to read this. ~W3Schools Modstaff~
iwato

The $_SESSION Variable and performance.navigation.type Property

Recommended Posts

Please open to this page and click on the image.  It will open to another page whereupon two pop-up light boxes will appear.  The goal of the following code is to suppress the pop-ups when, and only when, the image is clicked.  Obviously it fails.

.htaccess File

<IfModule mime_module>
    <Files overview.html>
        AddType application/x-httpd-ea-php56 .php .html
    </Files>
</IfModule>

this page http://www.grammarcaptive.com/single_payment_acknowledgment.php

<?php
	session_start();
	$_SESSION['perform_nav'] = 1;
?>

Target Page - http://www.grammarcaptive.com/overview.html

<?php
	session_start();
?>
<script>
	var navtype = <?php echo $_SESSION['perform_nav']?>;
	if(typeof navtype != "undefined" && navtype !== null) {
		performance.navigation.type === 1;
	}
</script>

The Javascript  - http://www.grammarcaptive.com/_utilities/javascript/overview.js

if (performance.navigation.type === 0) {
			$.colorbox({opacity: '0.70', transition: 'elastic', speed: 700, width: 700, height: 'auto', scrolling: false, html:"<div id='welcome_slide'> <table> <tr> <td width=250 height='auto'> <img src='_images/freed_captive.png' height=200 width=200 /> </td> <td width=450 height='auto'> <h1>Hi!</h1><h2>My name is Roddy.</h2> <p class='welcome'>This is your gateway out of the prison of bad grammar.</p><p>Let me show you to the final gate!</p></td> </tr> </table> </div>",
				onClosed: function() {
					$("iframe.splash").colorbox({iframe: true, fastiframe: false, fixed: false, opacity: "0.65", open: true, rel: 'sweet', width: 700, height: 450, closeButton: true, href: function(){
							  var href = $(this).attr('src');
							  return href;
					}
				});
			}});
}

 

REQUEST: Can you suggest any adjustment that might produce the desired effect?

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

It appears that I have asked a question about which the gurus of W3Schools are unwilling to respond.  But why?  One does not have to know the answer in order to discuss the issue.  Indeed, might the discussion not shed enough light to spark a flame and the answer?

Happy Halloween!

halloween_2017.jpg

Roddy

Share this post


Link to post
Share on other sites

I've been pretty busy so I've just been answering short questions that don't need a lot of research.

I think you probably intended to do an assignment here instead of a comparison.

if(typeof navtype != "undefined" && navtype !== null) {
	performance.navigation.type === 1;
}

I actually have never worked with the performance.navigation object, so I don't even know what it's for. I'll look it up once I have the time.

  • Like 1

Share this post


Link to post
Share on other sites

Yes, you are correct.  Unfortunately, it does not solve the problem.  The colorbox pop-up still appears.

in answer to your question:  one of the uses of performance.navigation.type is to control what happens when a user refreshes the page.  For example, go to http://www.grammarcaptive.com/overview.html and observe the pop-ups.  Then, refresh the window.  The pop-up do not reappear.  Then go to http://www.grammarcaptive.com/single_payment_acknowledgment.php and click on the image.  The pop-up reappear whether the overview.html has been loaded already or not.

I am trying to convince the browser to treat the call from single_payment_acknowledgment.php as a simple refresh.

i hope that you passed an enjoyable Halloween!

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

You could use a sessionStorage variable to only open the popup once per session. I'd have to look into this in more detail later.

  • Like 1

Share this post


Link to post
Share on other sites

At the suggestion of Ingolme I have introduced a $_SESSION variable.  Unfortunately, the only affect that it appears to have is to prevent my Javascript from loading in Firefox and Chrome, this despite my continued ability to use Javascript  with Safari.  I simply do not understand.

 Perhaps I have become impatient.  Perhaps my desire to move forward has overcome my ability to think clearly and achieve my task.

Reference Page:  http://www.grammarcaptive.com/single_payment_acknowledgment.php

<?php
	session_start();
	$_SESSION['navtype'] = 1;
?>

Target Page:  http://www.grammarcaptive.com/overview.html

<?php
	session_start();
	$navtype = filter_var($_SESSION['navtype'], FILTER_VALIDATE_INT);
?>
<script>
	var navtype = <?php echo $navtype;?>;
</script>

Javascript Page for Target Page:  http://www.grammarcaptive.com/_utilities/javascript/overview.js

$( document ).ready(function() {
    console.log( "ready!" );
  if (navtype == 1) {
      $.colorbox({open:false});
  } else if (performance.navigation.type === 0) {
              $.colorbox({opacity: '0.70', transition: 'elastic', speed: 700, width: 700, height: 'auto', scrolling: false, html:"<div id='welcome_slide'> <table> <tr> <td width=250 height='auto'> <img src='_images/freed_captive.png' height=200 width=200 /> </td> <td width=450 height='auto'> <h1>Hi!</h1><h2>My name is Roddy.</h2> <p class='welcome'>This is your gateway out of the prison of bad grammar.</p><p>Let me show you to the final gate!</p></td> </tr> </table> </div>",
                  onClosed: function() {
                      $("iframe.splash").colorbox({iframe: true, fastiframe: false, fixed: false, opacity: "0.65", open: true, rel: 'sweet', width: 700, height: 450, closeButton: true, href: function(){
                                var href = $(this).attr('src');
                                return href;
                      }
                  });
              }});
  }
});

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

Yes and No.

Yes, I did miss it when I first posted it.

No, I caught it and reloaded it with the semi-colon.  I simply forgot to make the adjustment here.

In the end, it makes no difference.  The negative effects and the failed good effect remain unfortunately in tact.

Woe is me.

Roddy

p.s. I will correct the error above.

Share this post


Link to post
Share on other sites

Could you not look at the PHP correspondence that I have created and suggest why it does not work.  All of the links provided above  are valid.

My THREE STEPS to Failed Nirvana.

1) Start a session with the reference page and pass a $_SESSION variable to the target page from the reference page.

2) In the target page create from the $_SESSION variable a Javascript variable and assign to it the value of the $_SESSION variable.

3) Load the page and upon completion execute a $(document).ready() function that checks the value of the variable and determines whether or not to allow $.colorbox to display.

Roddy

Share this post


Link to post
Share on other sites
<IfModule mime_module>
    <Files overview.html>
        AddType application/x-httpd-ea-php56 .php .html
    </Files>
</IfModule>

The above code was placed in a .htaccess file in the same directory that contains all of the aforesaid files.

Edited by iwato

Share this post


Link to post
Share on other sites

Although we are closer, I am afraid to say that we are almost there, because I have learned that , unless I know for sure,  the smallest matter can take an indefinite amount of time to repair.

Please click on the image after the following page opens http://www.grammarcaptive.com/single_payment_acknowledgment.php.

It would appear that the first Colorbox has been suppressed, but not the second.  

 if (navtype == 1) {
      $.colorbox({open:false});
} else if 

I have now tried to fix the problem by

  1. doubling the content of the if-statement.
  2. concatenating the same line of jQuery as $.colorbox({open:false}).colorbox({open:false});
  3. adding the following second line of code:  
    $("iframe.splash").colorbox({open:false});
  4. adding an onclose callback function to the first call to Colorbox using the same code in item 3.

All of the these produce the same half-positive result.

Any additional ideas?

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

Let's start off at the very beginning. These are your requirements:

Quote

The goal of the following code is to suppress the pop-ups when, and only when, the image is clicked.

But you have another requirement:

Quote

go to http://www.grammarcaptive.com/overview.html and observe the pop-ups.  Then, refresh the window.  The pop-up do not reappear.

So to summarize your requirements:

Display popups on the page any time it loads except under the following conditions:

  • The user arrived on the page from clicking that image.
  • The user has refreshed the page.

Now we have to determine the following:

  • How do we know that the user clicked on that image?
  • How do we know that the page was refreshed?

The resulting logic should be very simple:

if(!clickedOnImage() && !pageRefreshed()) {
  showPopups();
}

function clickedOnImage() {
  // Return true if and only if the image was clicked
  // Return false otherwise
}

function pageRefreshed() {
  // Return true if and only if the page was refreshed
  // Return false otherwise
  return performance.navigation.type == 1;
}

function showPopups() {
  // All the code that creates the popups is in here
  // This code is irrelevant to the problem we're solving
}

How do you want to detect that the request came from the image? Is it alright to pass data in a query string or hash in the URL? You could make the image a link with the following href attribute: href="overview.html?fromimage=1" and then use the location.search property in Javascript to check for that value.

Another option, if you only care that it came from the page that the image is on rather than the image itself, is to check the document.referrer property. clickedOnImage() returns true of document.referrer is " http://www.grammarcaptive.com/single_payment_acknowledgment.php "

  • Thanks 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×