【问题标题】:Automatically jump to a certain part of a web view自动跳转到网页视图的某个部分
【发布时间】:2016-10-06 14:05:01
【问题描述】:

我正在制作一个 Chrome 应用程序,我正在使用类似于 iframe 的 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();
};
}

我的 content.js:

window.scroll(0, 150);

html:

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

【问题讨论】:

标签: javascript jquery html css google-chrome-app


【解决方案1】:

试试这个:

JQuery 代码

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

【讨论】:

  • 不适用:目标不是滚动包含#wvembedding页面,而是embedded里面#wv的页面(它的作用类似于 iframe)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-01-15
  • 1970-01-01
  • 1970-01-01
  • 2018-12-15
  • 1970-01-01
  • 2014-05-03
  • 2015-06-03
相关资源
最近更新 更多