By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,237 Members | 1,537 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,237 IT Pros & Developers. It's quick & easy.

Help with embedding JavaScript page

P: 6
I have this page: http://www.bekdavis.com/jcarousel/examples2/diane.html

and I need to embed it on the following page: http://www.scentsy.com/diane

http://www.scentsy.com/diane - I can only add a small snip of code to this page & I do not want it to be in a frame.

What would the code look like?

Thanks in advance!!!
bek davis
Jan 30 '09 #1
Share this Question
Share on Google+
11 Replies


ivosilva
P: 17
Hello, bekdavis!

I don't know how to measure a "small snip of code" but here is one way you could do it:

- create a JavaScript file with a function that makes an XML HTTP Request (Ajax) to the page you wish to include. Also place a call to that same function in this file.

- in the main page include the JavaScript file and a placeholder for the request response.

Best regards.
Jan 31 '09 #2

Nepomuk
Expert 2.5K+
P: 3,112
Maybe an iframe? Or would that still count as a frame for you?

But I must admit, I don't see where this is connected to Java at all. If you could explain that, this might be the right place. Otherwise I'd be happy to move this thread somewhere else for you (e.g. the HTML / CSS or the JavaScript / Ajax Forum).

Greetings,
Nepomuk
Jan 31 '09 #3

P: 6
here we go....

the following page is a combo of html and java that I made. http://www.bekdavis.com/jcarousel/examples2/diane.html

I need to make the above page display on the following page: http://www.scentsy.com/diane

I cannot just copy and paste the HTML code b/c I am limited on the amount of code I am able to use. The page http://www.scentsy.com/diane is a replicating Network Marketing site and I am only allowed to put a tiny bit of code into the page to personalize it.

I want to be able to "display" all of the content that is on the page I created (http://www.bekdavis.com/jcarousel/examples2/diane.html).

I have tried the following and it does not work:

<object
type="text/x-scriptlet"
width=475 height=1024 data="http://www.bekdavis.com/jcarousel/examples2/diane.html">
</object>

also...

<!--#include file="http://www.bekdavis.com/jcarousel/examples2/diane.html" -->


is there a way to place some java code on http://www.scentsy.com/diane to make my HTML created page display?

does this make sense?
Jan 31 '09 #4

Nepomuk
Expert 2.5K+
P: 3,112
Well, I checked that first site out and all I can find is HTML, CSS and JavaScript. Are you sure it's Java and not JavaScript you're refering to? (Although the some of the names suggest, that you're right and it is actually Java.)

Now, it would be great to know what type of code you can use for your second page (e.g. which language(s)) and what the length-limit is. Without knowing the tools, we won't be able to help you, I guess.

Oh, and why can't you use frames? I'm sure there's a good reason, but knowing the reason might help too.

Greetings,
Nepomuk
Jan 31 '09 #5

P: 6
this is the script i used to make the page: http://sorgalla.com/jcarousel/

Honestly, I am not sure what type of code I am allowed to use. I can tell you that there is another "replicating site" that has inserted the following code

Expand|Select|Wrap|Line Numbers
  1. <link href="http://www.XXXXX.com/cart/stylesheet.css" type="text/css" rel="stylesheet" /></p>
  2. <!--[if IE]><link type="text/css" rel="stylesheet" href="http://www.XXXXX.com/cart/ie.css" /><![endif]--><script type="text/javascript">
  3.     document.write('<script type="text/javascript" src="http://XXXXXX.com/cart/store-renderer.php"><\/script>');
  4. </script>
Frames: I need for my page to flow as if it were part of the replicating website page.

here is an example of what I am talking about. I don't want to link directy to it. You know where to place the DOTS.
www scentsy com/alice
Jan 31 '09 #6

Nepomuk
Expert 2.5K+
P: 3,112
OK, after checking that page I'm pretty sure, we're talking about JavaScript and maybe some Ajax, so I'm moving this thread to the JavaScript / Ajax Forum. I'm sure, our experts there will be willing and able to help you.

I can however think of one more question: Do you have the possibility to upload files (e.g. .js files) somewhere to one of those servers? If so, that could probably make life a lot easier.

Anyway, I'll let our JavaScript / Ajax Experts do their work from here on.

Greetings,
Nepomuk
Jan 31 '09 #7

P: 6
Thanks so much!!!

No, I am not able to upload any files to the replicating website. I can however upload files to the bekdavis.com website. ;)
Jan 31 '09 #8

P: 6
any idea anyone? I would appreciate any ideas you may have.

Thanks in advance.

bek
Feb 3 '09 #9

ivosilva
P: 17
Hi, bekdavis!

As I mentioned on my first reply you can use Ajax. Here's a solution you could use:

1. Add this code to http://www.scentsy.com/diane:

Expand|Select|Wrap|Line Numbers
  1. <div id="bekdavis"></div>
  2. <script type="text/javascript" src="http://www.bekdavis.com/jcarousel/examples2/include.js"></script>
  3.  
2. The include.js file looks like this:

Expand|Select|Wrap|Line Numbers
  1. function includePage(url, placeHolderId) {
  2.  
  3.     var xmlhttp = false;
  4.  
  5.     /*@cc_on @*/
  6.     /*@if (@_jscript_version >= 5)
  7.     // JScript gives us Conditional compilation, we can cope with old IE versions.
  8.     // and security blocked creation of the objects.
  9.      try {
  10.       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  11.      } catch (e) {
  12.       try {
  13.        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  14.       } catch (E) {
  15.        xmlhttp = false;
  16.       }
  17.      }
  18.     @end @*/
  19.  
  20.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  21.         try {
  22.             xmlhttp = new XMLHttpRequest();
  23.         } catch (e) {
  24.             xmlhttp=false;
  25.         }
  26.     }
  27.  
  28.     if (!xmlhttp && window.createRequest) {
  29.         try {
  30.             xmlhttp = window.createRequest();
  31.         } catch (e) {
  32.             xmlhttp=false;
  33.         }
  34.     }
  35.  
  36.     xmlhttp.open("GET", url,true);
  37.         xmlhttp.onreadystatechange=function() {
  38.         if (xmlhttp.readyState==4) {
  39.             document.getElementById(placeHolderId).innerHTML = xmlhttp.responseText;
  40.         }
  41.     }
  42.  
  43.     xmlhttp.send(null);
  44. }
  45.  
  46. includePage("http://www.bekdavis.com/jcarousel/examples2/diane.html", "bekdavis");
  47.  
Additional notes:

- Your include page will have images, links, ... if you include it as is, without any change it simply won't work. Full URL for images and links must be supplied and every link should be specially crafted to use Ajax, otherwise when users click a link it will be either invalid or will redirect them to another page.

- This is one possible solution to your problem given the restrictions you imposed but, as Nepomuk stated an iframe should do the job just fine, even if the user has to scroll it would spare you a lot of development time.

Best regards!
Feb 3 '09 #10

P: 6
Thanks for your reply. I have tested the code here: http://www.bekdavis.com/code.html and I am having problems. The scrollinig images are not displaying as on the original page: http://www.bekdavis.com/jcarousel/examples2/diane.html

What am I doing wrong? I really do appreciate your help & don't mean ot be a pain in the butt. ;)
Feb 4 '09 #11

ivosilva
P: 17
Hello, bekdavis!

I was checking out my code and making some tests and realized that it was first tested in the same domain which is not what you want.

The problem you are having is related to carousel not being initialized (since the Javascript code and includes of the included page are not evaluated). You would also have to include the jquery.js and carousel.js in the page and initialize the carousel after setting the innerHTML of the place holder.

Anyway, as I was saying, that code will only work when you are in the same domain since Ajax is not allowed to make cross-domain calls. My bad :(

I guess you really have to go with the iframe.

Best regards!
Feb 4 '09 #12

Post your reply

Sign in to post your reply or Sign up for a free account.