Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7759603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:40:21+00:00 2026-06-01T13:40:21+00:00

In my project, I have created a code snippet which can be copied and

  • 0

In my project,

I have created a code snippet which can be copied and then put in any website. It shows my content on other websites.

What I am using now is :

<script type='text/javascript'>
var user = 'abc';
var age = '23';

document.write('<iframe src="http://www.mysite.com/page.php?user='+ user + '&age=' + age + '" ></iframe');
</script>

In page.php,

I do some processing based on user and age and show dynamic content.

My approach works fine.

But when I look into some good standard ways to do such tasks, I find a different way.

Take an example of google adsense code.

<script type='text/javascript'>
 var a = 'somedata';
 var b = 'someotherdata';
</script>

<script type='text/javascript' src='http://www.google.com/adsenseurl.js'></script>

I guess, since a and b are global; adsenseurl.js must be using it and may be finally they are showing it on iframe.

So, now the question.

What’s the advantage in using google’s approach and whats wrong in my approach ?

p.s. I know I should try to avoid using iframes but I dont see any other way to accomplish this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:40:22+00:00Added an answer on June 1, 2026 at 1:40 pm

    The main difference between your approach and adSense is in my opinion that your code has to be placed where the ads have to appear and loading a script like adsense, they can place the iframe in the DOM after examining the page – using

    var myIframe = document.createElement('iframe');
    .
    .
    someDOMObject.appendChild(myIframe);
    

    and/or manipulating the zindex to float the iframe above the page

    Lastly the iFrame is useful (regardless of “oh noes – iframes are evil” you may hear) since you can use any css and jquery you like. If the page you are on already has styled divs and old versions of jQuery you will have a lot more work to make it look like you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a library which can download JSON data which is then placed
I have a project where a .master page was created without a code behind
i have below code snippet in my legacy project DetachedCriteria subCriteria = DetachedCriteria.forClass(Employee.class); subCriteria.setProjection(Projections.distinct(Property.forName
I have created a project in MVC 3 using code first and nugget ,
I have the following code. <s:push value=#session['person']> <s:if test=%{admin=='y'}> <a class=add href=/projit1/project/addProject.jsp>Create a Project</a>
For a new project I have created a local folder tree with empty Visual
I have created a project in Dashcode, inserted a List control, enabled a dynamic
I have created a project that uses scala that has some abstract classes definitions
I have created SSRS project in BIDS and I want to use the reports
I have created a setup project using Visual Studio 2008. After the application is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.