Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-10-2011, 01:32 PM   PM User | #1
Jones_Rob
New to the CF scene

 
Join Date: Feb 2011
Location: UK
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Jones_Rob is an unknown quantity at this point
[JQuery] Trouble replacing inline HTML with external HTML page

Hi,

I'm a novice with javascript though I've hacked scripts before to satisfy my own requirements - however this is too tricky for me to work out alone. Any help or guidance to solving this is very much appreciated.

So I'm looking to throw up a popup lightbox on my page after a few seconds delay. The code I have is:

Code:
<script type='text/javascript' src='jquery.js'></script>
<script type='text/javascript' src='lightbox.js'></script>

<script type="text/javascript">
var popup_domination = {"defaults":{"Name":"Your First Name...","Email1":"Your Email Address..."},"delay":2,"cookie_time":1,"center":"Y","cookie_path":"\/","show_opt":"open","unload_msg":"Would you like to signup to the newsletter before you go?","impression_count":0,"output":"<div class=\"popup-dom-lightbox-wrapper\" id=\"popup_domination_lightbox_wrapper\" style=\"display:none\">my content goes in here<\/div>"};
</script>
You'll notice the content is inline, but what I'd like to do is use an external HTML file - it saves me having to escape all the HTML within the javascript y'see...

I'm guessing the "output":"<div class=\"popup-dom-lightbox-wrapper\" id=\"popup_domination_lightbox_wrapper\" style=\"display:none\">my content goes in here<\/div>" is what I need to change - but how could I load and external HTML file in here instead?

Many thanks,

Rob.
Jones_Rob is offline   Reply With Quote
Old 02-10-2011, 05:07 PM   PM User | #2
venegal
Gütkodierer


 
Join Date: Apr 2009
Posts: 2,127
Thanks: 1
Thanked 426 Times in 424 Posts
venegal has a spectacular aura aboutvenegal has a spectacular aura about
You would have to use AJAX for that. jQuery actually makes that very easy; it would look something like that:

PHP Code:
$.get('/url/of/the/file.html', function (html) {
    
// Whatever you want to do. The html parameter holds the contents of your HTML file.
}); 
venegal is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:52 PM.


Advertisement
Log in to turn off these ads.