dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: Change Image size in Jscript without css

  1. #1
    Join Date
    Jan 2017
    Posts
    1

    Change Image size in Jscript without css

    I have a java script that I embedding into our cms. The css is externally hosted so cannot change. But wondered how to change the size of the image within the javascript divclass if possible?

    The image is huge and I would like to resize so that the width is proportional against the height

    <div class="candid-embed" data-host="api.getcandid.com" data-id="c99469e1-5476-4aaa-90eb-b7d940882f0f" data-ids="172262754475694502" data-theme=""></div><script async defer src="//api.getcandid.com/scripts/embed.js"></script>


    css

    element.style {
    border:0;
    border-radius:4px;
    box-shadow:rgba(0, 0, 0, 0.498039) 0 0 1px 0px, rgba(0, 0, 0, 0.14902) 0 1px 10px 0;
    height:1143px;
    margin:1px;
    max-width:658px;
    overflow:hidden;
    width:calc(100% - 2px);

  2. #2
    Join Date
    Dec 2012
    Posts
    1,555
    I'm afraid that this is not possible due to the same origin policy:
    https://en.wikipedia.org/wiki/Same-origin_policy
    Your script creates an iframe containing the image and some other content. The URL of that iframe is
    //api.getcandid.com/stream/embed/?id=c99469e1-5476-4aaa-90eb-b7d940882f0f&amp;ids=172262754475694502&amp;theme=&amp;cache=false
    As the domain is different from your own, the browser will reject access to that iframe.
    Last edited by Sempervivum; 01-10-2017 at 12:11 PM.

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    5,429
    Why not just host on your domain and then you can do pretty much what you want...
    --> JavaScript Frameworks like JQuery, Angular, Node <--
    ... and please remember to wrap code with forum BBCode tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

  4. #4
    Join Date
    Jan 2017
    Location
    Ahmedabad
    Posts
    37
    Hi,
    You can Try Following code

    You have to make sure the javascript is executed after the page is finished loading. You can do this by putting it in an onload event.

    HTML Code:
    var Img = document.getElementById('ImgId');
    if(Img && Img.style) {
        Img.style.height = '100px';
        Img.style.width = '200px';
    }

    All the Best try this code it may be help to you.

    Thanks
    krishna Agola

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center