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 8828719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:40:18+00:00 2026-06-14T07:40:18+00:00

I am writing a jQuery plugin. In this plugin I wrap the existing BODY

  • 0

I am writing a jQuery plugin. In this plugin I wrap the existing BODY contents in a DIV and hide them.

var $originalBodyContents = $('body').wrapInner('<div>').children('div').hide();

The plugin then appends its own overlay DIV to the BODY and does it’s plugin magic. When the user exits the plugin removes its overlay DIV, and unwraps them.

$originalBodyContents.children().unwrap();

This is working great, as you can see in this demo:
http://jsfiddle.net/vKddB/1/

However, if there are content scripts on the page then they are all reloaded when the wrap occurs and they run their code again. This is causing a lot of unexpected behavior, as you can see in this demo:
http://jsfiddle.net/vKddB/3/

In the above demo you’ll see that the “Show Alert” button shows an alert that says “hello!” when clicked. If you fire the plugin and close the plugin you’ll notice that the “Show Alert” button now has two click handlers tied to it so it shows two alerts when clicked.

My plugin will not have control over the contents of the page it is running on. Is there a way I can prevent the inline scripts from re-running when I wrap the body contents in a DIV?

  • 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-14T07:40:20+00:00Added an answer on June 14, 2026 at 7:40 am

    $('script', $('body')).remove(); before your code

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

Sidebar

Related Questions

In a JQuery plugin I'm writing I want to hide all the contents of
I'm writing a jQuery plugin , which similar to this, $(this).each(function(){ $el = $(this).find('.el')
I am writing a jQuery plugin to simulate an editable div. Here is my
I'm writing my first jQuery plugin based on this documentation and I have a
I'm now writing my first jQuery Plugin and i found this blog post about
I'm writing a helper class to wrap the functionality of JQuery Taconite plugin. The
I'm writing a little plugin for jQuery and so far I've got this: (function($){
I am writing a jQuery plugin which makes use of two nested <DIV> elements.
I'm writing a jQuery plugin and I am trying to do this: $(this).height>=options.maxHeight ?
I'm writing a jQuery plugin that makes containers (e.g. a div) of a hyperlink

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.