How to recognize MS Edge

Hi

I have a script that is use to call just a small part of a full page and display as a popup.

It has a problem inasmuch as it does not work properly in the new MS Edge. Until a solution is found for the problem, I wonder if it is possible to add something to the script to detect when the visitor is using Edge and disable it. With the script disabled the full page is displayed.

Hi

Try this:

if (navigator.userAgent.indexOf('Edge') >= 0){
    /* ...code for Edge.... */
} else {
    /* ...code for other browsers... */
}

Or, if you want to simple stop script in Edge, add one line at the beginning of the script:

if (navigator.userAgent.indexOf('Edge') >= 0){ return; }

Hi megazoid

That was quick!

Where do I put it?

(function() {
   'use strict';

function init(){
   var left=document.getElementById('left');
   var right=document.getElementById('right');
   var box4=document.getElementById('box4');
    var head=document.getElementById('head');
   var nav=document.getElementById('nav');
   var horizontal2=document.getElementById('horizontal2');
 var footer=document.getElementById('footer')
   var hgt=[left.offsetHeight,right.offsetHeight,box4.offsetHeight];
        hgt=(Math.max(hgt[0],hgt[1],hgt[2]));

  


if(window.name=='newwindow') {
if(document.getElementById('name')){
   document.getElementById('name').style.display='';
 }
   header.style.display='none';
   nav.style.display='none';
   horizontal2.style.display='none';
   left.style.display='none';
   right.style.display='none';
   footer.style.display='none';
   box4.style.width='820px';
document.getElementById('popup-test').innerHTML=
   '<h3><a href="#">Close<\/a><\/h3>'+
   '<h4><\/h4>'+
  '<h3><a href="Punta.php" target="top"><\/a><\/h3>';
var anc=document.getElementById('popup-test').getElementsByTagName('a');
for(var c=0;c<anc.length;c++) {
anc[c].onclick=function() {
   window.close();
   return false;
    }
   }
  }
 }

   window.addEventListener?
   window.addEventListener('load',init,false):
   window.attachEvent('onload',init);

})();

It depends on what are you planning to do when it’s Edge.
If you want to “disable” init() function add this:

if (navigator.userAgent.indexOf('Edge') >= 0){ return; }

right after:

function init(){

Sorry, I did’t read your post properly.

So, I place the line right at the beginning, ruight?

function init(){
if (navigator.userAgent.indexOf('Edge') &gt;= 0){ return; }
   var left=document.getElementById('left');
   var right=document.getElementById('right');
   var box4=document.getElementById('box4');
    var head=document.getElementById('head');
   var nav=document.getElementById('nav');
   var horizontal2=document.getElementById('horizontal2');
 var footer=document.getElementById('footer')
   var hgt=[left.offsetHeight,right.offsetHeight,box4.offsetHeight];
        hgt=(Math.max(hgt[0],hgt[1],hgt[2]));
[/quote]

Yes, it should work

Sorry… it doesn’t.

Look at the last 2 hotels of http://pintotours.net/Americas/DomRepublic/Punta.php

They should have opened as a full page ignoring the popup script but they are still doing something strange.

problem is you told me you don’t have Edge to try…

Haha you did the exact thing I was afraid you’ll do

You have copied a line from your badly formatted previous post, with &gt;= instead of >=

Here is correct version, copy it and replace:

if (navigator.userAgent.indexOf('Edge') >= 0){ return; }

Yeah, I’m on Linux Mint now so can’t try it in Edge

1 Like

There’s always an answer to everything!

It’s working. I can put the popups back in place.

Now, I can relax and wait for Edge to sort out its problems

I am still curious to understand why the popups in the Sydney page work with Edge and the one for the Vik hotel with the same code does not work in the Punta Cana page. That might be the first step to understand the problems.

Hi megazoid

The only small problem with the script now, for Edge, is that it is opening in a NEW page rather then reusing the page. It is not very important but is there a way round this?

…and now that I see the popups opening in the other browsers ( see http://pintotours.net/Americas/DomRepublic/Punta.php ) , I see that the popup opens right at the top. How can I get it to open further down?

EDIT

…and unfortunately it did not solve the original problem… the affiliate links still open in a reduced size page, the size of the popups. Can we use the same method for this?

Edge is a brand new browser - it appears to have a number of bugs i it that should have been fixed before it was released but which are yet to be fixed. Once it is fixed any patches you put in place to work around what is currently broken will then break it instead of fixing it.

Hi felgall

I am in touch with MS on this and they have responded. So, in a couple of years, or five it should be fixed…

The fix I thought solved the problem temporarily is only a line of code n the script which will not take too long to delete if the problem is fixed, and I am happy if it stays like this for a while.

The big, big problem, which was the original problem is that even with the fix the links at the bottom of the FULL page open up as a reduced window the size of the popup that is no longer a popup! Diabolical!

How can I get round that, please?

On the assumption that you can do anything you want with javascript, all I need now is a line of code to insert in the script to say

if Edge open page links in full page

Is that easy?

But then it would have to directed to the link and not the actual popup as it is not as popup any longer…

I think the problem here is that the link goes via a redirtect, but why that should affect the page id beyond me!

Years? :open_mouth:

Edge isn’t like IE9-11, etc. Edge is supposed to have rolling updates which should provide a more “FF/Chrome” experience with more updated fixes and features.

Hi Ryan

I hope so!

Meanwhile, could you look at my current script problems?

  1. bring the popup down a bit (see how high they open in http://pintotours.net/Americas/DomRepublic/Punta.php )

  2. how to tell the script to open in full size any external links

Thanks

PARTLY SOLVED

  1. was due to the line

    Look inside

The height was too high… changed it 650 and all’s well.

Still need to find a solution for 2)

Thanks

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.