Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

.js script wont open or fire in and external file when using a Math.min() and Math.max() object.

$
0
0

.js script wont open or fire in an external file when using a Math.min() and Math.max() object. Math.min() and Math.max()

Math.min() and Math.max() can be used to find the lowest or highest value in a list of arguments:  

<!DOCTYPE html>
<html>
<body>
<p>Math.min() returns the lowest value.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
    document.getElementById("demo").innerHTML =
    Math.min(0, 150, 30, 20, -8, -200);
}
</script>

</body>
</html>

I split up the script and used

function myFunction() {
    document.getElementById("demo").innerHTML =
    Math.min(0, 150, 30, 20, -8, -200);
}

 in the .js file exactly as seen above no <script> was included and it didn't work, or fire. Yes I placed the first part in an html file calling the .js file like this:

<!DOCTYPE html>
<html>
<body>
<p>Math.min() returns the lowest value.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>

</body>
</html>

Now I have successfully include various js files without a hitch but any Math objects or math methods don't appear to be able to work, I am running  IE11. But it doesn't work on google browsers either. I even successfully fired a transitional script a red square that moves diagonally down screen, so what can I try. Also I have conbined scripts, here is how it looks from the Html script:

<!DOCTYPE html>
<html>
<style>
#container {
  width: 400px;
  height: 400px;
  ;
  background: yellow;
}
#animate {
  width: 50px;
  height: 50px;
  ;
  background-color: red;
}
</style>
<body>
<p>
<button onclick="myMove()">Click Me</button>
</p>
<div id ="container">
<div id ="animate"></div>
</div>
 
    <head>
<script src="redrectangle.js">
</script>
</head>

<body>
<input type="button" onclick="popup()" value="Click this!">
</body>
<head>
<script src="redrectangle.js">
</script>
</head>

<p>Infinity is returned if you calculate a number outside the largest possible number.</p>
<button onclick="myFunction1()">Try it</button><p id="demo"></p>
<head>
<script src="redrectangle.js">
</script>
</head>

</head><body>
Enter your name: <input type="text" onfocus="myFunction(this)">
<p>When the input field gets focus, a function is triggered which changes the background-color.</p>  </body>
 
<body>
<p>Math.min() returns the lowest value.</p>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
</body>

<html> 

 

this is on the .js script:  


function myMove() {
  var elem = document.getElementById("animate");  
  var pos = 0;
  var id = setInterval(frame, 5);
  function frame() {
    if (pos == 350) {
      clearInterval(id);
    } else {
      pos++;
      elem.style.top = pos + 'px';
      elem.style.left = pos + 'px';
    }
  }
}
function popup() {
alert("Hello World")
}     
          
function myFunction(x) {
    x.style.background = "yellow";
}
     
function myFunction() {
    document.getElementById("demo") =
    Math.min(0, 150, 30, 20, -8, -200);
}
  

  so any takers out there that can provide an answer I seem to be stumped.


Viewing all articles
Browse latest Browse all 3527

Trending Articles