javascript - 自动跳转到网页 View 的某个部分

标签 javascript jquery html css google-chrome-app

我正在制作一个 Chrome 应用程序,我正在使用类似于 iframe 的 WebView 标签。

有没有办法在网页 View 中加载一半的网页?

我试过:

应用程序.js:

$(document).ready(function () {
// Assuming <webview id="wv"></webview>
var webview = document.getElementsById("wv");
webview.addContentScripts([{
name: "ExampleRule",
matches: ["http://sentifeed.marstons.co.uk/Index.aspx"], // can be as narrow as you wish
js: ["content.js"]
}]);
webview.src = "http://sentifeed.marstons.co.uk/Index.aspx";

var webview = document.getElementsById("wv");
webview.executeScript({
file: "content.js"
});

$(".box1").click(function () {
$(".header").css("position", "fixed");
$(".bookAtable").fadeIn(1000);
$(".content").hide();
$(".headerPara").slideUp();
$(".back").css("visibility", "visible");
$(".marstonsLogo").css({
    "opacity": "0.0",
    "height": "48px"
});
});

$(".box5").click(function () {
$(".sentifeed").fadeIn(1000);
$(".content").hide();
$(".headerPara").slideUp();
$(".back").css("visibility", "visible");
$(".marstonsLogo").css({
    "opacity": "0.0",
    "height": "48px"
});
$(".header").css("position", "fixed");

});
$(".box3").click(function () {
$(".inmoment").fadeIn(1000);
$(".content").hide();
$(".headerPara").slideUp();
$(".back").css("visibility", "visible");
$(".marstonsLogo").css({
    "opacity": "0.0",
    "height": "48px"
});
$(".header").css("position", "fixed");

});

$(".back").click(function () {
$("webview").hide();
$(".content").fadeIn(1000);
$(".headerPara").slideDown();
$(".back").css("visibility", "hidden");
$(".marstonsLogo").css({
    "opacity": "1.0",
    "height": "75px"
});
$(".header").css("position", "relative");

});

$(".login").click(function () {
$(".boxWrapper").show();
$(".login-page").slideUp(600);

});

});

window.onload = function () {
document.querySelector(".exit").onclick = function () { //close windows button
    window.close();
};
}

我的 content.js:

window.scroll(0, 150);

html:

<webview id="wv" class="sentifeed"></webview>

最佳答案

试试这个:

JQuery 代码

$('html, body').animate({
        scrollTop: $('#wv').offset().top //wv id of webview
}, 1000); //Time to scroll

关于javascript - 自动跳转到网页 View 的某个部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39898161/

相关文章:

javascript - Angular Material 日期选择器格式语言环境

javascript - angular js渲染如果

javascript - CSS 替代 CSS 加号选择器?

jquery - 无法使用类设置 div 的高度

javascript - 我如何制作一个动态的CSS类?

javascript - jQuery 确定元素是否具有固定宽度或动态宽度

jquery - Chrome 中的 HTML5 音频控制问题

PHP - 如何编辑已显示在 HTML 表格中的 PHP 表格的内容?

html - 在 Doxygen 中调整导航树面板的大小

javascript - Aurelia:调整大小/布局更改事件以供查看?