javascript - Getting the on screen Width of a element -


in order provide full quality in canvas wanted use actual amount of pixel canvas using on screen. content of webpage coding fixed 465px. can imagine, canvas 465px not nice. , since modern monitors have way more pixel, thought use advantage. tried different things innderwidth, clientwidth , normal width nothing worked. need function changes when reload browser different zoom.

html:

<div id="mytargetdiv"></div> 

javascript:

<script>     $("#mytargetdiv").html("<canvas id='mycanvas' style='widt: 100%" width="         + document.getelementbyid("contentmain").clientwidth + "' height='"         + document.getelementbyid("contentmain").clientheight         + "'>your browser not support html5 canvas tag</canvas>"); </script> 

i'd glad if provide solution in js or in jquery

set width , height of element 100%. make sure parent elements 100% width/height.

html, body, #mytargetdiv {   width: 100%;   height: 100%; } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -