Creating markup for embedded Google Calendar using JavaScript

Hi Experts!

I am utilising Google Calendars within a clients website, at the moment by simply using the embedded iframe method.  Instead of using Googles customisation tool, I have created a javascript function to generate the iframe markup, because I want to embed different calendars at different points around the site, and do not want to have to keep using the Google Customisation Tool each time I want to make a change.  Eventually I will utilise the Calendar API, but when I have more time.

I have attached a standalone example.  The problem that I am having is that when the iframe element is inserted into the DOM, the entire page redirects to the Google Login page.  I do not understand why?  These are public calendars and should not require the user to be logged in.

I have tried inserting iframe HTML, inserting the iframe DOM element, and even setting the src attribute after the DOM element is inserted.  What gives?  I am obviously missing something here.. Any ideas?

TIA, TheFoot
LVL 12
Barry JonesAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Albert Van HalenAnalyst developerCommented:
Replace & with & in the url you're constructing.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Barry JonesAuthor Commented:
Bloody hell!  Awesome - thanks a bunch.
Barry JonesAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.