Calling a javascript

746 views
Skip to first unread message

filippi leonardo

unread,
Dec 15, 2014, 11:34:04 AM12/15/14
to gwd...@googlegroups.com
Hi guys, let´s go!

1 - I put an expandable banner in an iframe;
2 - I made a script to increase the size of the iframe.
3 - I want when click a banner button, that call javascript;
4 - Where do I put the function calling javascript?

How will I call the function from within an iframe, I will put it this way:

window.parent.myScript();

I've done several tests and could not solve it. Does anyone know where I put this function?

Thanks!

Google Web Designer beta

unread,
Dec 15, 2014, 12:19:38 PM12/15/14
to gwd...@googlegroups.com
hello,

I'm assuming you're creating an expandable ad in GWD. That ad comes pre-built with a tap area, that, when clicked, will expand the ad (i.e. go to the expanded page). For example, see a function called 'gwd.handleExpand_buttonAction' in the 'handlers' script block. This function gets executed when the button on the banner gets clicked. Within this function you can add any custom JS code you'd like to execute in addition to the expansion.

If this does not answer your question, can you describe your document setup a little more? I'm not sure why you want to increase the size of the iframe directly. If you prefer, you can send your document zip to gwd-s...@google.com.

Hope this helps,
    Pushkar (GWD team)

Matt Phillips

unread,
Dec 15, 2014, 12:56:19 PM12/15/14
to gwd...@googlegroups.com
Another important thing to mention on this, which may or may not influence your continued use of that method, is same-origin policy. If you're writing a script that can resize the iframe when the banner is clicked, then you should be able to reference the script from the GWD ad, however, it will only be able to access elements of the parent document if they are on the same domain. If you're looking to deploy this ad on sites on a different domain, that'll be trouble. 

     -Matt-

filippi leonardo

unread,
Dec 15, 2014, 1:13:34 PM12/15/14
to gwd...@googlegroups.com
The banner was made to be used only on the personal website. It will not be used for adsense, or on another site. Only in my client's site.

Do not worry, I'm already working with the program for a while now. But so far I do not know how to call a javascript in the code. I believe that should be simple.

I want that when the banner expands, the click also call a javascript. This will increase the javascript iframe. And when you close calls another javascript. Wish somebody would tell "Insert that line your script."

Pushkar, I did not find this handler in the program. But I thought the banner code. Me know that AdSense has everything ready, but how to a personal website, I need to do this.

I'm trying something for hours but get nothing.

Thanks guys!

Google Web Designer beta

unread,
Dec 17, 2014, 11:06:07 AM12/17/14
to gwd...@googlegroups.com
Hi,

Just to confirm, did you do the following when creating the expandable in GWD?
1. File->New File
2. Select 'Expandable' under Google Ads
3. Give the file name and hit 'Ok'.

At this point you should have an expandable ad with two pages: a 'Banner' page and an 'Expanded' page. If you look in the Events panel on the right, you'll see the first event handler is for the expand-button (this handler is executed when one clicks or taps anywhere on the Banner page). In terms of actual code, this function is called 'gwd.handleExpand_buttonAction' (which you can find if you go to Code view).

Now, to insert your custom JavaScript code, you have two options: you can edit the gwd.handleExpand_buttonAction function in code view, or you can create a new custom action for the expand-button. The steps for this second option are:
1. Right-click on the banner page and select 'Add Event'. This will bring up the events dialog with the target pre-selected as the expand-button tap area.
2. Under 'Event' in the events dialog, select Tap Area->Touch/Click.
3. Under 'Action', select Custom->Add custom action
4. Give your new custom action (i.e. function) a name and enter its code in the text box underneath the name. This is where you will add code to increase the size of the iframe.
5. Hit 'Save'. Now your custom action is registered as an event handler for the expand-button click event.

filippi leonardo

unread,
Dec 17, 2014, 4:58:17 PM12/17/14
to gwd...@googlegroups.com
Hi everyone!

Thanks for the effort in trying to solve, but not this working.

I sent an email to "gwd-s...@google.com". The subject is "Problem with iframe."

In this email client application and the banner attached.

Thank you!
Reply all
Reply to author
Forward
0 new messages