Nickname-no
@Nickname-no

Как запустить function при открытие страницы?

Как сделать так чтобы при открытие страницы срабатывал onclick

<a href="#" onclick="requestFullScreen(document.documentElement); return false;">открыть текущее окно</a>

<script>
function requestFullScreen(element) {
    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
    if (requestMethod) {
        requestMethod.call(element);
    } else if (typeof window.ActiveXObject !== "undefined") { // для IE
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript !== null) {
            wscript.SendKeys("{F11}");
        }
    }
}
</script>
  • Вопрос задан
  • 189 просмотров
Пригласить эксперта
Ответы на вопрос 2
xmoonlight
@xmoonlight
https://sitecoder.blogspot.com
<a href="#" onclick="requestFullScreen(document.documentElement); return false;">открыть текущее окно</a>

<script>
function requestFullScreen(element) {
    var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
    if (requestMethod) {
        requestMethod.call(element);
    } else if (typeof window.ActiveXObject !== "undefined") { // для IE
        var wscript = new ActiveXObject("WScript.Shell");
        if (wscript !== null) {
            wscript.SendKeys("{F11}");
        }
    }
}
window.onload=function() {
  requestFullScreen(document);
}
</script>
Ответ написан
Комментировать
Rou1997
@Rou1997
В конец последнего script добавьте:
requestFullScreen(document.documentElement);
Либо используйтеwindow.onload
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы