Page 1 of 1

Open an HTML scrip in a new tab?

Posted: Wed Mar 16, 2022 4:33 pm
by alan_sh
I have some html code which I have been given (see below). When I execute it in an HTML object, it works fine apart from 2 issues:

1. The resultant button is quite small
2. The script opens a new web page in the same tab - I would like it to open in a new tab.

Can anyone help me with either (or both) of these issues?

The code is

Code: Select all

<div id="CAFDonateButtonContainer"></div> <script type="text/javascript"> var caf_BeneficiaryCampaignId=20130; document.write(unescape('%3Cscript id="CAFDonateButtonLoader_script" src="https://cafdonate.cafonline.org/js/CAF.DonateButtonLoader_script.js" type="text/javascript"%3E%3C/script%3E')); </script>
Thanks

Alan

Re: Open an HTML scrip in a new tab?

Posted: Wed Mar 16, 2022 4:59 pm
by crispy68
First let me say, I'm not a javascript expert.

The problem I see is that the button image and links are being injected using javascript into the html. The link and image doesn't exist until the script is called. Now there may be a way using javascript to inject the "target=_blank" code into the anchor after that script loads but i'm not sure how to do it or if it would work 100% of the time.

The other problem is the image. There is css you can apply to the button to make it bigger but the problem is it distorts the image. The image for the button is a fixed size. So wherever the image is being pulled from needs to be changed in size rather than doing it after it is loaded.

These are 2 attributes that need to be adjusted on the end where they are originating from.

Re: Open an HTML scrip in a new tab?

Posted: Wed Mar 16, 2022 7:01 pm
by alan_sh
Thanks - I can't amend the JS script as I don't own it. So, I guess I'll just live with it.

cheers

Alan

Re: Open an HTML scrip in a new tab?

Posted: Wed Mar 16, 2022 7:01 pm
by lummis
Were you just given a script or did you follow the CAF guidelines at https://www.cafonline.org/charities/caf ... -form#tab2 where there are additional instructions?

Re: Open an HTML scrip in a new tab?

Posted: Wed Mar 16, 2022 10:38 pm
by alan_sh
Just the script. Thanks for the link. I'll see if there are further options.

Alan