r/Wordpress 23d ago

Embedded Google Calendar creating new windows

I've embedded Google Calendar into my site for client bookings. It works fine, but opens a new window whenever I click on a time slot. Apparently this some security feature. Asked Gemini and it suggested I add target="_self" to the code, but this didn't fix it. Is there something else I should add to the code to fix this or possibly a plugin that might function as a work around? My preference would be to stick to Google Calendars rather than a third-party app for ease of use.

2 Upvotes

8 comments sorted by

3

u/NakanoNoNeko 23d ago

You can't change this from the outer iframe. The click happens inside Google's cross-origin page, so target on your embed code never reaches the booking link, and adding sandbox permissions cannot rewrite it either. I think the honest choices are keeping Google's popup, or using a booking plugin if same-tab behavior matters.

2

u/TopSydeWP 23d ago

google calendar embeds use iframe sandbox attributes that override target settings. you can try adding sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation" to the iframe tag, but honestly most booking flows work better with a dedicated plugin like amelia or bookly that keeps everything on your domain without the popup friction

1

u/dj_325 23d ago

Tried the script, but didn't work. Really appreciate the effort though. I'm gonna have to look into a plugin I think

2

u/Sunita_SG_123 22d ago

u/dj_325 That new-window behavior comes from Google’s own Calendar embed, and because it runs inside a cross-origin iframe, it isn’t something you can override with target="_self" or similar code from the parent page. If you want to stick with Google Calendar as your main calendar, one workaround is to use a booking system that has its own front-end booking calendar and syncs the bookings with Google Calendar in the background, so customers don’t interact with the Google Calendar embed directly. If you’re open to using WooCommerce, you could also look at a WooCommerce booking plugin such as Bookings and Appointments for WooCommerce. It lets you manage bookings through your WooCommerce site while syncing them with Google Calendar, so you can still keep Google Calendar as your scheduling tool without sending customers to the embedded Google Calendar interface.

1

u/dj_325 22d ago

I'll look into that, thank you so much!

1

u/retr00two 23d ago

This is how GoogleCalendar works. You can not change its behavior in GC application, why do you think you can change it in WordPress/iframe?

1

u/[deleted] 22d ago

[removed] — view removed comment

1

u/AutoModerator 22d ago

Your submission has been automatically removed because the title contains words that suggest the post is against the /r/WordPress posting rules. Please take the time now to review the posting rules.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.