How to change ADS.JS so that the advertisement width is 100%

349 views
Skip to first unread message

Yzer Zhang

unread,
Apr 25, 2018, 3:38:44 AM4/25/18
to Interactive Media Ads SDK
How to change ADS.JS so that the advertisement width is 100%. Instead of specifying pixels, can you specify the exact location of the code, thank you!

ima-sdk-adv...@google.com

unread,
Apr 25, 2018, 4:42:09 AM4/25/18
to ima...@googlegroups.com
Hi,

You should be able to apply the 100% width of your ad via the style.css file instead of your ads.js file. You may refer below as to how :

#adContainer {
width: 100%;
}

Let me know if this helps.

Best regards,
Peter Laurence N. Oliquino
IMA SDK Team


On 04/25/18 15:38:43 who...@gmail.com wrote:
How to change ADS.JS so that the advertisement width is 100%. Instead of specifying pixels, can you specify the exact location of the code, thank you!

--
You received this message because you are subscribed to the Google Groups "Interactive Media Ads SDK" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ima-sdk+unsubscribe@googlegroups.com.
To post to this group, send email to ima...@googlegroups.com.
Visit this group at https://groups.google.com/group/ima-sdk.
For more options, visit https://groups.google.com/d/optout.

Yzer Zhang

unread,
Apr 25, 2018, 8:51:03 AM4/25/18
to Interactive Media Ads SDK
I tried it, but it doesn't work. The above method changes the width of the container. When the advertisement is played, only the width is set.
Thank you very much

在 2018年4月25日星期三 UTC+8下午4:42:09,ima-sdk-adv...@google.com写道:

ima-sdk-adv...@google.com

unread,
Apr 26, 2018, 12:01:50 AM4/26/18
to ima...@googlegroups.com
Hi,

My apologies for if I did not fully understand your issue initially. That said, the IMA SDK should already display the 100% width and height of your ad. Resizing it can be done through the AdsManager's init or resize method.

However, since you are asking, I would assume that you maybe encountering ads that are not being displayed fully. This being said, if you could provide an ad tag for reference then I could investigate this issue further. You may reply to me via the Reply privately to author option.

Thanks and regards,
Peter Laurence N. Oliquino
IMA SDK Team

Yzer Zhang

unread,
Apr 26, 2018, 9:02:16 AM4/26/18
to Interactive Media Ads SDK
Hi.Peter
Thank you very much for your patience in answering my question, but I still don't understand. Now I sent you my code. I found that the code to change the ad size is line 68 in ADS.JS and can only be set to absolute value. Cannot be set as a relative value, I sent you a screenshot, the address of my test page is http://www.cloudz360.com/gad/spm/index.html
 Now I want the ad to be filled with DIV "adContainer".thank you very muah!


ima-sdk-adv...@google.com

unread,
Apr 27, 2018, 3:20:55 AM4/27/18
to ima...@googlegroups.com
Hi,

I took a look at the sample app that you sent and it appears that when click on the Play button, your init() method is indeed assigning a width=300px and height=250px and is not adapting to the size of your video player. As a recommendation, you may first want to get the width and height of your video player then later on apply the appropriate values in the init() method of your ads.js file. As an example, you may try something similar to the one below :

  var initWidth, initHeight;
  if (this.application_.fullscreen) {
    initWidth = this.application_.fullscreenWidth;
    initHeight = this.application_.fullscreenHeight;
  } else {
    initWidth = this.videoPlayer_.getWidth();
    initHeight = this.videoPlayer_.getHeight();
  }
  adsManager.init(
    initWidth,
    initHeight,
    google.ima.ViewMode.NORMAL);

Yzer Zhang

unread,
Apr 27, 2018, 4:11:17 AM4/27/18
to Interactive Media Ads SDK
Thank you very much, your method worked, but the code to get height and width should be:offsetHeight and offsetWidth.
Thank you again!!!


Reply all
Reply to author
Forward
0 new messages