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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:04:55+00:00 2026-06-14T06:04:55+00:00

I have written a bookmarklet that receives a Django form and inserts it into

  • 0

I have written a bookmarklet that receives a Django form and inserts it into the Dom via the innerHtml of a new div element created via javascript and appended to the body of an existing html document. The first submit is an ajax request (works fine), if the form is rejected by Django due to an unknown user, the submit function is unbound from ajax and resubmitted without ajax to a pop-up window to authenticate the user without CORS. The process works flawlessly in IE but crashes the chrome tab when the submit button is clicked.

Tests: I thought maybe it was the initial ajax submit that was causing the issue. However, if i use the same process without ajax upon injection, submit fails as well. If i copy the html code from the browser after my injection is complete and create a new html document then open it in chrome everything works fine. Also if i delete the div containing the form fields prior to injection the submit button works. This leads me to believe that it has something to do with injecting the form after the Dom on the existing page has loaded. Is there a way to reload the Dom without a page refresh or force the innerHtml to properly register in the Dom on injection?

No console errors, just an aww, snap! Somethng went wrong while displaying this webpage.

To replicate the issue follow these steps: (I am on windows 8 with Chrome Version 23.0.1271.64 m)
(step 1) goto an immage url: itsblackcurrent.com/wp-content/uploads/2012/07/what-hi.png
(step 2) go to chrome console and enter the following code:

o = document.createElement("div");
o.setAttribute("id", "overlay");
o.innerHTML = '<div class="modal fade" id="new-pin"><div class="modal-header"><h3>New Pin</h3></div><form action="" enctype="multipart/form-data" method="get" id="ajaxform" name="pin_form" class="form-horizontal"><div class="modal-body"><div id="div_id_url" class="control-group"><label class="control-label" for="id_url">URL</label><div class="controls"><input type="text" name="url" id="id_url" /></div></div><div id="div_id_image" class="control-group"><label class="control-label" for="id_image">or Upload</label><div class="controls"><input type="file" name="image" id="id_image" /></div></div><div id="div_id_description" class="control-group"><label class="control-label" for="id_description">Description</label><div class="controls"><textarea id="id_description" rows="10" cols="40" name="description"></textarea></div></div><div id="div_id_tags" class="control-group"><label class="control-label" for="id_tags">Tags</label><div class="controls"><input type="text" name="tags" id="id_tags" /></div></div></div><div class="modal-footer"><div class="messageContainer"></div><button id="btnsubmit" type="submit" class="btn btn-primary">Submit</button><a id="cancel" onclick="removeOverlay()" data-toggle="modal" class="btn">Cancel</a></div></form></div>'; 
document.body.appendChild(o);

(step 3) Click submit and see Chrome crash!

(step 4) If the exact same code is loaded prior to DOM loading it works. Paste the following into a new text document and save as .html.

<body>
<script>
Copy and paste all the code from step 2 here
</script>
</body>

(step 5) Open the .html file with chrome and submit will not crash.

  • 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-14T06:04:56+00:00Added an answer on June 14, 2026 at 6:04 am

    I figured out how to prevent the crash in chrome and also works in IE! So we can call this a cross browser way to inject a form after the dom loads without causing a crash in chrome.

    $('#form').submit(function () {
        formData = $("#form").serialize()
        window.location = "http:url.to.submitdata/?"+formData;
        return false;
    });
    

    First we have to create a custom submit function by capturing the submit() with jQuery. Then serialize the form data, and manually append the form data to the url where you want to submit the form. Finally & most importantly return false stops the normal submit function and prevents chrome from crashing!

    IF YOU FOLLOWED THE INSTRUCTIONS TO REPLICATE THE ISSUE IN MY ORIGINAL QUESTION, HERE IS HOW YOU CAN TEST THE WORKAROUND FOR CHROME:

    (step 6) complete steps 1 & 2 from my original question.
    (step 7) enter the following code in the chrome console:

    s = document.createElement("script")
    s.src = src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"
    document.body.appendChild(s);
    jQueryCheckLoad();
    
    function jQueryCheckLoad() {
        if( window.$) {
            console.warn("jquery is ready");
            jqReady();
        } else {
            window.setTimeout( jQueryCheckLoad, 10 );
        }
    }
    function jqReady() {
        $( '#ajaxform' ).submit(function () {
            formData = $( "#ajaxform" ).serialize()
            window.location = "http://url.to.submitdata/?"+formData;
            return false;
        });
    }
    

    (step 8) You will see “jQuery Ready” warning in the console, then click submit and BOOM! NO CRASH!

    All we did was prevent the normal submit() from firing by creating a custom jQuery submit() that returns false. First we injected jQuery, then used jQueryCheckLoad() to wait for jQuery to be ready. Then bound our jQuery submit().

    *If anybody has any idea what is causing the crash in chrome i would still love to know. The strangest part is that when i first did the unbind and submitted the form it worked very consistently for about 2 hours of testing then just mysteriously started crashing constantly. There is a small chance i modified my injection order and did not clear the cache on the bookmarklet, and when i did it started crashing. This leads me to believe that there is a way to successfully reload the DOM without a page refresh.

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

Sidebar

Related Questions

Background: I have written a bookmarklet (JavaScript) that appends an iframe to the current
Background: I have written a bookmarklet (JavaScript) that appends an iframe to the current
I have written a program that reads a csv file and put it into
I have written a function that sorts a big scale of data. To test
I have written a function that extract the domain from hostname. e.g. www.domain.com ->
I have written a very simple CTE expression that retrieves a list of all
I have written a raw binary image file into a buffer which is an
Have written the following code: m_selectCategoryTableWidget = new QTableWidget; m_selectCategoryTableWidget->setRowCount(0); m_selectCategoryTableWidget->setColumnCount(2); m_selectCategoryTableWidget->setHorizontalHeaderLabels(QStringList()<<tr(Category)<<tr(Number of items));
I have written the following code. I know that a higher order function is
I have written a WCF service with the REST template that has the defaultOutgoingResponseFormat

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.