J'ai passé en revue toutes les questions connexes mais je n'ai pas pu obtenir de réponse.WPF WebBrowser Taille du contenu
Comment obtenir la taille actuelle du contenu du contrôle WebBrowser dans WPF?
J'ai passé en revue toutes les questions connexes mais je n'ai pas pu obtenir de réponse.WPF WebBrowser Taille du contenu
Comment obtenir la taille actuelle du contenu du contrôle WebBrowser dans WPF?
Pour déterminer la taille réelle (en utilisant javascript) de la fenêtre du navigateur, en utilisant les propriétés suivantes:
dans Internet Explorer (mode compatibilité ascendante):
document.body.offsetWidth, document.body.offsetHeight
dans Internet Explorer (mode standard , document.compatMode == 'CSS1Compat'):
document.documentElement.offsetWidth, document.documentElement.offsetHeight
dans la plupart des autres navigateurs:
window.innerWidth, window.innerHeight
The following code sets the variables winW and winH to the actual width and height of the browser window, and outputs the width and height values. If the user has a very old browser, then winW and winH are set to 630 and 460, respectively.
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
winW = document.body.offsetWidth;
winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth) {
winW = document.documentElement.offsetWidth;
winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
winW = window.innerWidth;
winH = window.innerHeight;
}
document.writeln('Window width = '+winW);
document.writeln('Window height = '+winH);
Dans votre navigateur, ce code produit la sortie suivante:
Window width = 1280
Window height = 675
Notes: