Open an HTML scrip in a new tab?

This section is for posting questions which are not directly related to WYSIWYG Web Builder.
Examples of off topics: web server configuration, hosting, programming related questions, third party scripts.

Note that these questions will generally not be answered by the administrators of this forum.
Post Reply
alan_sh
 
 
Posts: 1870
Joined: Tue Jan 01, 2019 5:50 pm

Open an HTML scrip in a new tab?

Post 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
User avatar
crispy68
 
 
Posts: 3059
Joined: Thu Oct 23, 2014 12:43 am
Location: Acworth, GA
Contact:

Re: Open an HTML scrip in a new tab?

Post 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.
alan_sh
 
 
Posts: 1870
Joined: Tue Jan 01, 2019 5:50 pm

Re: Open an HTML scrip in a new tab?

Post 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
lummis
 
 
Posts: 223
Joined: Sun Apr 24, 2011 9:18 am
Location: UK

Re: Open an HTML scrip in a new tab?

Post 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?
alan_sh
 
 
Posts: 1870
Joined: Tue Jan 01, 2019 5:50 pm

Re: Open an HTML scrip in a new tab?

Post by alan_sh »

Just the script. Thanks for the link. I'll see if there are further options.

Alan
Post Reply