N
N
nadom2015-05-14 19:31:48
Bootstrap
nadom, 2015-05-14 19:31:48

Why does the page refresh occur in the script?

There is a simple script.
Under debugging, when stepping through, everything works, but when I call the function by clicking on the button, it doesn’t work (I think it’s because of a page refresh).
Help spot the error.

<input type="button" name="stay" onclick="skip_fun()" value="skip"/>

function red_fun () {
  var newWin = open ("Results.html", "Results");
  
  var ptr = newWin.document.body.children [0];
  var content = window.document.forms[0].elements[0];
  var size = window.document.forms[0].elements[1].value;
  
  if (size == "Small")
    ptr.insertAdjacentHTML("afterEnd", "<p class='red-text small-text'></p>");
  if (size == "Medium")
    ptr.insertAdjacentHTML("afterEnd", "<p class='red-text medium-text'></p>");
  if (size == "Large")
    ptr.insertAdjacentHTML("afterEnd", "<p class='red-text large-text'></p>");
  ptr = newWin.document.body.children [1];
  ptr.insertAdjacentHTML ("afterBegin", content.value);

}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Daniil Ivanov, 2018-06-09
@DanialKA

If you want exact dimensions, don't use bootstrap. It is not justified here and is not needed.
For the middle, set the width, margin auto, position relative. For right position absolute, left 100%, top 0, bottom 0, width.

D
Denis Ineshin, 2015-05-14
@IonDen

You call the skip_fun function, and in the code it has a different name red_fun.
And your page is updated probably because the button is inside the form.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question