Javascript 自动跳转到web视图的特定部分

Javascript 自动跳转到web视图的特定部分,javascript,jquery,html,css,google-chrome-app,Javascript,Jquery,Html,Css,Google Chrome App,我正在制作一个Chrome应用程序,我正在使用类似于iframe的web视图标签 有没有一种方法可以在web视图中加载一半的网页 我试过: application.js: $(document).ready(function () { // Assuming <webview id="wv"></webview> var webview = document.getElementsById("wv"); webview.addContentScripts([{ name:

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

有没有一种方法可以在web视图中加载一半的网页

我试过:

application.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();
};
}
html:


试试这个:

JQuery代码

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

相关:注意:我列出的两种方法几乎是互斥的。不要同时使用它们。不适用:目标不是滚动包含
#wv
的嵌入页面,而是滚动嵌入
#wv
中的页面(其作用类似于iframe)
<webview id="wv" class="sentifeed"></webview>
$('html, body').animate({
        scrollTop: $('#wv').offset().top //wv id of webview
}, 1000); //Time to scroll