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:

and I need to embed it on the following page: - 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

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

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).

Jan 31 '09 #3

P: 6
here we go....

the following page is a combo of html and java that I made.

I need to make the above page display on the following page:

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 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 (

I have tried the following and it does not work:

width=475 height=1024 data="">


<!--#include file="" -->

is there a way to place some java code on to make my HTML created page display?

does this make sense?
Jan 31 '09 #4

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.

Jan 31 '09 #5

P: 6
this is the script i used to make the page:

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="" type="text/css" rel="stylesheet" /></p>
  2. <!--[if IE]><link type="text/css" rel="stylesheet" href="" /><![endif]--><script type="text/javascript">
  3.     document.write('<script type="text/javascript" src=""><\/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

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.

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 website. ;)
Jan 31 '09 #8

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

Thanks in advance.

Feb 3 '09 #9

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

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

Expand|Select|Wrap|Line Numbers
  1. function includePage(url, placeHolderId) {
  3.     var xmlhttp = false;
  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 @*/
  20.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  21.         try {
  22.             xmlhttp = new XMLHttpRequest();
  23.         } catch (e) {
  24.             xmlhttp=false;
  25.         }
  26.     }
  28.     if (!xmlhttp && window.createRequest) {
  29.         try {
  30.             xmlhttp = window.createRequest();
  31.         } catch (e) {
  32.             xmlhttp=false;
  33.         }
  34.     }
  36."GET", url,true);
  37.         xmlhttp.onreadystatechange=function() {
  38.         if (xmlhttp.readyState==4) {
  39.             document.getElementById(placeHolderId).innerHTML = xmlhttp.responseText;
  40.         }
  41.     }
  43.     xmlhttp.send(null);
  44. }
  46. includePage("", "bekdavis");
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: and I am having problems. The scrollinig images are not displaying as on the original page:

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

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.