Reputation: 3357
*I am new to clienside development and not sure if this is appropriate question for stackoverflow, do let me know if I should move this somewhere else.
I need to create a client side widget (think loan calculator) which can be hosted as a public page and needs to do following
Architecturally I am thinking of creating jquery widget using html and css. Host a page somewhere on the public site.
Question 1: What is the best way to load widget inside the page ? Load public url via iFrame or use jquery to render DIV dynamically on page load.
i.e.
<script id="jsCal" />
<div id"containerCal" class="default" />
Question 2: What is the best way to style this widget ?
Thanks
Upvotes: 0
Views: 216
Reputation: 1656
An iframe won't inherit the styles of the parent page by default. You can get around this by using Javascript to load the parent's stylesheets into the DOM, but then you're requesting the files twice.
I think a more problematic issue would be that you're going to have to define dimensions for an iframe code snippet. If you have a script that renders the calculator inline, you can set it up to fit the dimensions made available to it, whether it's a big content area, a small sidebar, a mobile device, etc. Iframe dimensions can, of course, be changed but if this is being distributed to technically-disinclined users, it would probably be easier if it just "worked" as easily as possible without requiring their intervention.
Conversely, if you are distributing a script to be distributed on a variety of sites and CMS platforms, an iframe may be easier because some CMS platforms will strip out <script>
tags by default.
Your requirements are fairly loose though. Everything I just outlined is correctable. Technically speaking, either way would probably work perfectly fine.
Upvotes: 1
Reputation: 2599
A very broad question, but I'll give it a go. First, go here to get an idea where to begin on the JavaScript/jQuery side of things.
Upvotes: 1