<noscript> not working in Opera 11? - javascript

I am testing my noscript tags which display content when javascript is disabled, this works in Safari, Chrome, Firefox, Camino, IE6, IE7, IE8, IE9, basically everything but Opera (I'm running version 11, not sure if its isolated to that version).
In Opera 11 nothing is displayed... is the noscript tag not supported? and what is the alternative?
Nothing surprising:
<noscript>Please enable JavaScript.</noscript>
Located between the body tags.
<html>
<body>
<script>alert('Hello World');</script>
<noscript>Hello World!</noscript>
</body>
</html>

Are you sure you disabled javascript in Opera:
Menu >> Settings >> Preferences >> Content >> Deselect "Enable Javascript"
If so, then post the contents of your entire file here.
EDIT
Until they fix this bug in version 11 which I reckon will happen shortly you can try this:
<script type="text/javascript">
<!--
document.write("<style type='text/css'>.noScript { display: none; }</style>");
//-->
</script>
<span class="noScript">Please enable javascript in your browser.</span>
You are basically using javascript to show css which hides the no script message, but if javascript is disabled then there is no way that css can be displayed hence the message will show.

Uh, yeah. We (as in Opera) broke <noscript> in Opera 11. Known bug.

Implementation of <noscript> is buggy and inconsistent and not recommended. You'd be better off doing something like:
<span class="noscript">Please enable JavaScript.</span>
You can then use JavaScript to hide anything with a class of "noscript" on page load. People with JavaScript disabled will see the message because it won't be hidden.

Hrm. I had wrapped a meta refresh within a noscript, so that a page could automatically reload if a certain set of elements within it couldn't reload via javascript. I can't see any alternative like the hack involving hiding CSS elements. My original thought was perhaps to set a meta refresh header, but override that to not refresh at all if the javascript could execute, but I can't see any ways for javascript to redefine the page refresh time.

try this
<span class="noscript"></span>
<noscript>Please enable JavaScript.</noscript>

The noscript element isn't recommended. It won't work if scripts are partially blocked (e.g. by a corporate firewall or the NoScript extension, or just a temporary DNS failure).
Build on things that work instead.

This works well for me... (Tested in IE, Opera, and FireFox)
<p id="js_disabled">
<script type="text/javascript">
document.getElementById('js_disabled').style.display = 'none';
</script>
Javascript is disabled or not supported by your browser.<br/>
Javascript must be enabled...
</p>
The JavaScript runs immediately so the noscript message never appears.
The idea is to place the JavaScript code immediately following the noscript's opening tag, in this case the paragraph tags.

Related

window.opener is null... didn't use to be

In our software, we have a page with a link that opens a page within the same site in a new tab using target='_blank'. When the user is done working on that newly opened page, they click a button and when the page refreshes, it calls the following code.
window.opener.location.href = window.opener.location.href; window.close();
This has worked fine for ages but within the last week or so stopped working in all browsers. I can't seem to find anything when I google it about a new security restriction being implemented that would cause this. Any idea what's going on and how to get it working again? I've tested the following code in chrome, firefox, edge and IE11. In all but IE11 window.opener is null. In IE it is not. Is there possibly a new security setting in browsers that would cause this?
<html>
<body>
click me
</body>
</html>
<html>
<body>
<script>
alert(window.opener === null);
</script>
</body>
</html>
I am not sure which version of chrome browser you tested your code on. To avoid "tab-napping" attacks, many browsers have started implementing noopener behavior by default for anchors that target _blank.
Chrome enabled noopener behavior in release 88.
Safari also enabled this in release 68.
I couldn't find any reference to IE 11 change. But it's worth trying adding rel="opener" in anchor tags with target=_blank

Hide Script tags From Chrome

Lets say if someone is accessing my website using a specific version of Chrome browser is there anyway to hide specific tags so that they don't execute on that browser with that version?
I've tried to give the script tag an id and then display:none; and show it if it has that id but apparently you can't hide script tags with css? Looking for another solution.
I've seen this: < ! [if lt IE 7] > for internet explorer but I am unfamiliar with it and how to use it for chrome. I've just started to learn code again after 5 years and the stuff I try and accomplish seem to be difficult for an amateur coder lol
Not exactly what you ask for, but in order to execute scripts in all webbrowsers but Google Chrome you can also do the following:
<script>
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(!is_chrome)
{
//Your Code goes here (won't be executed if it's Google Chrome)
}
</script>
You can actually use conditional comments to hide things from Internet Explorer contrary to the answer from deceze. (These are different from comments used to show things to internet explorer which are more common, those are known as 'Downlevel hidden conditional comments')
<!--[if lte IE 6]><![if gte IE 7]><![endif]-->
<!-- This is a bit mad, but code inside here is served to everything
except browsers less than IE7, so all browsers will see this -->
<!--[if lte IE 6]><![endif]><![endif]-->
"conditional comments" work only at older IE browser.
If you want to prevent to use some version or browser use:
https://github.com/mikemaccana/outdated-browser-rework or use function like this https://stackoverflow.com/a/5918791/8770040. Then when user use a specific version of browser remove every thing form page or show some overlay element.

Paypal In-Context Express Checkout button missing on IE

I have implemented Paypal's In-Context Express Checkout on a website (HTML and JQuery, no shopping cart, no CMS or anything), and it works perfectly on Firefox and Chrome for Windows, and Safari, Firefox, Chrome & Opera for Mac, but it doesn't work on IE.
Paypal's "Paypal Checkout" button is missing on IE. Every other browser has a button inserted which is the one that is clicked on to "activate" the checkout flow, but on IE the button is missing and thus the checkout flow is not activated.
The problem is ONLY on Internet Explorer. IE11, using X-UA-Compatible IE=EDGE.
Any help is greatly appreciated.
I don't see your integration but I'm guessing you're calling window.paypalCheckoutReady far later than the script is being inserted into the page and run, which will mean the paypalCheckoutReady event has already fired. To mitigate this and to prevent blocking the page load, the script tag should be at the end of your page before the closing </body> tag, and have the async attribute added to it.
It turns out that by moving the <script> tag with checkout.js from the <head> to the <body> right before the <form> tag, it works on IE.

Is there a way to block my website in IE and let it work in all other browsers

I have code on my website that IE seems to have a lot of trouble and keeps crashing and stuff, The good news is there is a 99.9% chance that the users that will be on my site will not be using IE, so I want to make my website available to all other browsers except IE. If they are using IE I just want a message saying something like "Unfortunately this website is not available in this browser" or something like that. Can I do this, if so, How?, I'm guessing JavaScript, right?
You can wrap your page content in conditional comments.
http://msdn.microsoft.com/en-us/library/ms537512%28v=vs.85%29.aspx
<body>
<!--[if IE]>
<p>Sorry, Internet Explorer is not supported.<p>
Use Firefox instead.
<![endif]-->
<![if !IE]>
<p>The page content for all other browsers.</p>
<![endif]>
</body>
Do it on the server side using the User-agent request header, that way you don't have to send all your page or could even send an alternate version.
You can use the navigator.appName variable in java script to have conditional if in your code to not display to internet explorer. A tutorial website is here:
http://www.w3schools.com/js/js_browser.asp
Can be done in pure HTML:
<!--[if !IE]>
all your code
<!--<![endif]-->
I would really suggest to fix what's broken instead. Otherwise, I suggest conditional comments(but rather not the whole body, just to refresh to a different website)

Jquery $('#someID > div').each(function(){..}) not working in IE

i don't face this problem while working on localhost only when I access the page using the ip address of my system this happens and it only happens with IE!! (works on all other browsers)
by the way i'm using Tomcat V6.0.0.29, IE8
I tried debugging the JS code using IE developer tools debugger, ofcourse when I open using http://localhost:8080/ everything works perfectly fine, but when I use http://myIP:8080/ this loop is giving a problem :-
$('#someId > div').each(function(){...});
As in this loop doesn't run at all, it just kind of skips it. I have checked the IDs they are fine moreover its working in localhost why should it give a problem when I access it using my IP?
Note :-
a. (correction) The problem is only there in IE7, it works perfectly in IE8.
b. As it turns out something weird is happening! i'm using IE8 when i open this webpage using localhost the developer tools shows its working in IE8 standards but when i use the IP address to access this page the developer tools shows its working in IE7 standards. When i changed the standards to IE8 it worked (using the IP address)!
c. But the problem is why the hell is it not working with IE7!! As in everything works except the loop mentioned above.
Finally i came to know what was causing the problem in IE7. Consider the below situation:-
<div id="div1">abc
<div id="div2">def
<div>hjs</div>
<div>zyx</div>
</div>
<div id="div3">xsj
<div>ask</div>
<div>iue</div>
</div>
</div>
The jquery i had written for traversing these divs was something like
$("#divId > div").each(function(){..});
Now for the first level div that is traversing the divs directly inside the div with id "div1" worked perfectly in IE7, but when i did something like:-
$("#div2 > div").each(function(){..});
This worked in all browsers (even in IE8!!) but not in IE7. This is because apparently IE7 requires the exact child selector for divs.
So for IE7 something like this needs to be written:-
$("#div1 > #div2 > div").each(function(){..});
for traversing the divs inside the div with id "div2"
So the problem was cause just by my lack of knowledge about IE7!!
sorry n thanks guys!
The culprit being IE it could turn out something as evil as the browser not caching the page when loaded from localhost, but reading it from cache when using the ip. Make sure you load the page to empty cache from your ip.
Check to see if your script is loaded when using your IP address. Sometimes browsers don't load scripts on special situations (for example when you want to load a script from an http source into an https page). Also you should check IE's security configuration.
To check whether your script is loaded and executed or not, simply put an alert('loaded') statement at the beginning of your code.
This may due to the group policy of your company for forcing Intranet sites using a specific version of IE in compatibility mode. I experienced exactly the same issue when I introducing some IE10+ Javascript libraries to my page.
To work around this you can either ask your company IT for changing the policy or force the browser to not using a compatibility view with the following tag.
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
More details for this tag can be found with the topic below.
StackOverflow - Force IE compatibility mode off using tags

Categories