I've been trying to get this work in my angular project, searching over the internet and it seems none of the possibles answers are helping me.
My console says:
Scripts may close only the windows that were opened by it.
Because I'm trying to close my current window with a button.
<button onclick="window.close();">Close window</button>
and of course the reasons is described at the console message. I can not close this window because this was not opened by javascript. At the first time my close window button was inside a ng-view and didn't work, after that I've moved my button to my index page outside the ng-view getting the same result :(
After those changes and other more that I've been found on internet, I've created a project from scratch, simple app, basically working just with the ng-app on index.html and a couple of controller that do nothing. AND this button works.
This works:
<!DOCTYPE html>
<html ng-app="myApp">
<head lang="en">
</head>
<body ng-controller="MyController">
<button onclick="window.close();">Close window</button>
</body>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script src="MyControllers.js"></script>
</html>
This is not working:
<!DOCTYPE html>
<!--[if lt IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html lang="en" ng-app="myApp" class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html lang="en" ng-app="myApp" class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" ng-app="myApp" class="no-js">
<!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>my web</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<my-nav-bar></my-nav-bar>
<div ng-view></div>
<button onclick="window.close();">Close window</button>
<script src="libs/jquery.js"></script>
<script src="libs/angular.js"></script>
<script src="libs/myapp/myapp.js"></script>
<script src="libs/myapp/mycontroller.js"></script>
<script src="libs/myapp/mydirectives.js"></script>
</body>
</html>
It says scripts may close only the windows that were opened by javascript but can anyone makes me notice if there any diference between this two html? if it's not, How the first html is following this rule and the second one doesn't'?
Related
I'm relatively new to coding and I'm trying to get number values from an HTML number input and then use that value in JavaScript.
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Phone Price Calculator</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../css/phonePrice.css">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please upgrade your browser to improve your experience.</p>
<![endif]-->
<p>How much money is in your bank account?</p><p>$ <input type="number" id="money" placeholder="ex. 9250.00"></input></p>
<p>How much are you willing to spend on a new phone?</p><p>$ <input type="number" id="newPhone" placeholder="ex. 130.00"></input></p>
<button type="button" id="spendButton">Spend Money!</button>
<p>Tax is 8.25%</p>
<hr>
<p id="total">Total: </p>
<script src="../js/phonePrice.js"></script>
</body>
</html>
--JavaScript--
let button = document.querySelector("button");
let money = document.getElementById("money").value;
let newPhone = document.querySelector("#newPhone").value;
let tax = 0.0825;
let total = document.getElementsByName("total");
button.addEventListener("click", function (){
console.log(money);
console.log(newPhone);
});
Both of my console.log statements return an empty string. I want to be able to set the variables to whatever input the user sets and then use those values (numbers) in my functions. Any help is greatly appreciated.
You assign values to money and newPhone when the script is loaded.
Then the user types something into the fields (which changes the values in the fields, but not in the variables) and clicks the button (which is when you use the values you collected earlier).
Collect the values when the button is clicked instead of when the script is loaded.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="Description" content="C.V"/>
I have added code below to render in IE but will not work.
<!--[if lt IE 9]>
<script src="Assets/html5shiv/html5shiv.js"></script>
<![endif]-->
<link rel="stylesheet" type= "text/css" href="Assets/aboutme.css"/>
if you want to target all versions of IE(except 10) use this:
<!--[if IE]>
<link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->
For IE 10 check this:
IE 10 Specific Styles
hope it helps.
EDIT:
and last, check this for IE 11 & 12+(EDGE) Detect Internet Explorer (IE) up to version 11 and Edge (12+)
I have a standard PHP/Smarty Website. There is a home base with index.php, a templates folder with the .tpl Files. I have a header.tpl, footer.tpl, index.tpl and subpage.tpl.
The index.tpl and subpage.tpl both include the header.tpl. I know they are both have the header.tpl included correctly because css is the same on both pages. In the head tag on the header.tpl I have a jQuery autocomplete script. If I have the text box on the index.tpl the autocomplete works.
If I place the same input text box code on the subpage The Autocomplete does not work. I force compile smarty, removed all cache and can't seem to figure out why? Any Ideas?
My Header .tpl
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html lang="en"> <!--<![endif]-->
<head>
... my css
<!--[if lt IE 9]><script src="//html5shim.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
<link rel="stylesheet" type="text/css" href="scripts/jquery.autocomplete.css" />
<script type="text/javascript" src="scripts/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.autocomplete.js"></script>
<script type="text/javascript" src="scripts/onchange.min.js"></script>
<script>
$(document).ready(function(){
$("#Part_Number").autocomplete("autocomplete/parts.php", {
selectFirst: true
});
});
</script>
my index.tpl and subpage.tpl
{include file="header.tpl" page="Home"}
<input type="text" id="Part_Number" name="Part_Number"></input>
The only thing that can be different in your 2 pages are the URI you are calling:
$("#Part_Number").autocomplete("autocomplete/parts.php", {
try to put an absolute path like this:
$("#Part_Number").autocomplete("http://www.example.com/autocomplete/parts.php", {
thanks for reading.
I have a simple problem that i can't solve. I just need to have a html map with Jquery fadeIn and fadeOut effects. I got it and it works everywhere except with IE8.
So i just wanna add a pure javascript already tested and working just when IE8 is present.
Obviously i tried writing this code but is not working even with a simple alert after the IE comment.
Can you help please?
Here's the code, thanks!
<script type="text/javascript">var runFancy = true;</script>
<!--[if IE]>
<script type="text/javascript">
runFancy = false;
alert(runFancy);
function showIt(name)
{
document.getElementById('map_image').src='immagini/distributori/8/'.concat(name).concat('.png');
document.getElementById('map_image').style.display='block';
}
function hideIt()
{
document.getElementById('map_image').src='immagini/distributori/8/map.png';
};
</script>
<![endif]-->
Here's the code for other browsers
<!--[if !IE]><!-->
<script type="text/javascript">
//alert('hi'); not working even just this
if (runFancy) {
function showIt(name)
{
document.getElementById('map_image').src='immagini/distributori/single/'.concat(name).concat('_single.png');
$('#mapon').fadeIn(400);
}
function hideIt()
{
$('#mapon').fadeOut(300);
};
}
</script>
<!--<![endif]-->
even this is not working, any advice?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
</head>
<body style="background-color:red">
<h1>Ciao</h1>
<!--[if IE]>
<style language="text/css">
body{background-color:black;}
</style>
<![endif]-->
</body>
</html>
not working with every IE version.
This will help you:
HTML:
<!doctype html>
<!--[if IE]><![endif]-->
<!--[if lt IE 7 ]> <html lang="en" class="ie6"> <![endif]-->
<!--[if IE 8 ]> <html lang="en" class="ie8"> <![endif]-->
<!--[if IE 9 ]> <html lang="en" class="ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
<head></head>
<body></body>
</html>
Javascript:
<!--[if IE 8]>
<script type="text/javascript" src="IE8.js">
<![endif]-->
the code you have should be working but if you want to target just IE 8 put IE 8 instead of just IE like so
<!--[if IE 8]>
do stuff
<![endif]-->
edit: removed depreciated jquery solution
I have been implementing Routing in my app following the tutorial
http://docs.angularjs.org/tutorial/step_07
I couldn't get my version to work in IE7, and after spending a while trying to work out what I have missed / done wrong I have noticed that the example doesn't work.
http://angular.github.com/angular-phonecat/step-7/app/
Anyone know how to get this to work?
OK I had the same problem so I started the bounty, but after that I found the working solution (for me at least):
Use HTML5 shim
Use JSON2.js
Add all these attributes to your html node:
class="ng-app:myapp" id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org"
(where myapp is really your app name)
So to recap, here is my IE7/8/9 working HTML page:
<!DOCTYPE html>
<html lang="en" class="ng-app:myapp" id="ng-app" ng-app="myapp" xmlns:ng="http://angularjs.org">
<head>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!--[if lte IE 8]>
<script>
document.createElement('ng-include');
document.createElement('ng-pluralize');
document.createElement('ng-view');
document.createElement('ng:include');
document.createElement('ng:pluralize');
document.createElement('ng:view');
</script>
<![endif]-->
<!--[if lt IE 8]>
<script src="js/json2.js"></script>
<![endif]-->
</head>
<body>
<div ng-view></div>
</body>
</html>