2016-10-06 53 views
0

私は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> 
+0

関連:http://stackoverflow.com/questions/39894014/automatically-jump-to-a-certain-part-of-a-webview/注:二つの方法私はリストはかなり排他的です。一緒に使用しないでください。 – Xan

答えて

-1

これを試してみてください。

jQueryのコード

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

適用されません。目標は、#wvを含む_embedding_ページをスクロールするのではなく、(#iframeと同様に動作する)#wvの中の_embedded_ページをスクロールすることです。 – Xan

関連する問題