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

The Archive Base Latest Questions

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

I am developing chrome extension. I loaded JavaScript file successfully but the problem is

  • 0

I am developing chrome extension. I loaded JavaScript file successfully but the problem is external JavaScript (which I have loaded) can not call the function of content script files my code is as follows.

$(document).ready(function() {
$('.main_list').click(function()
{
    $('.sub_list') .hide();
    $(this) .parent() .children('.sub_list') .slideToggle("normal");
});


$('#click') .click(function()
{
    $('.sub_list') .hide();
    $(this) .parent() .parent() .children('.sub_list').slideToggle("normal");
});


$('#btnnewtask').click(function()
{
    showdialog('http://localhost:51967/task.aspx');
});
$('#linknewtask').click(function()
{
    showdialog('http://localhost:51967/task.aspx');
});
$('#btnnewcall').click(function()
{
    showdialog('http://localhost:51967/call.aspx');
});
$('#linknewcall').click(function()
{
    showdialog("http://localhost:51967/call.aspx");
});
$('#btnnewmeeting').click(function()
{
    showdialog("http://localhost:51967/meeting.aspx");
});
$('#linknewmeeting').click(function()
{
    showdialog("http://localhost:51967/meeting.aspx");
});
});

Showdialog() is function in content script. It is as follow

function showdialog(url)
{
var xhr=new XMLHttpRequest();
xhr.onreadystatechange=function()
{
    if (xhr.readyState==4 && xhr.status==200)
        {
        xmldoc=xhr.responseXML;
        var js=getfile(getjavascript(xmldoc));
        for(i=0;i<js.length;i++)
        {
            loadjscssfile(js[i],"js");
        }
        var css=getfile(getstylesheet(xmldoc))
        for(i=0;i<css.length;i++)
        {
            loadjscssfile(css[i],"css");
        }
document.file.push(
{"url":url,"css":css,"js":js});
document.getElementById("dialogcontainer3").
innerHTML=gethtmldocument(xmldoc);
        document.getElementById("blacklayer").style.display="block";
        document.getElementById("dialogcontainer3").style.display=
"inline-block";
        document.getElementById("dialogcontainer2").style.display="block";
        document.getElementById("dialogcontainer1").style.display="block";
        }
}
xhr.open("GET",url,true);
xhr.send();
}

But it gives error

Uncaught ReferenceError: showdialog is not defined (program):1
(anonymous function) (program):1
b.event.dispatch (program):3
v.handle (program):3
  • 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-18T07:41:32+00:00Added an answer on June 18, 2026 at 7:41 am

    Content scripts execute in a special environment called an isolated
    world. They have access to the DOM of the page they are injected into,
    but not to any JavaScript variables or functions created by the page.
    It looks to each content script as if there is no other JavaScript
    executing on the page it is running on. The same is true in reverse:
    JavaScript running on the page cannot call any functions or access any
    variables defined by content scripts.

    See http://developer.chrome.com/extensions/content_scripts.html#execution-environment

    I would suggest trying shared DOM to communicate between the content script and the page or Message Passing.

    An example of code on the page would be:

    function showDialog(url) {
        window.postMessage({
            type: "FROM_PAGE",
            text: url
        }, "*");
    }
    

    And in the contentscript:

    // This function will NOT collide with showDialog of the page:
    function showDialog(url) {
        /* ... */
    }
    
    window.addEventListener("message", function (event) {
        // We only accept messages from ourselves
        if (event.source != window) { return; }
    
        // Make sure we're looking at the correct event:
        if (event.data.type && (event.data.type == "FROM_PAGE")) {
            showDialog(event.data.text);
        }
    }, false);
    

    I haven’t tested the above, so please consider it to be pseudocode. A similar example is available here: http://developer.chrome.com/extensions/content_scripts.html#host-page-communication

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

Sidebar

Related Questions

I am developing chrome extension, it is a simple extension which call background.js file
I'm developing a Google Chrome extension, which produces an error I can't fix. My
At the moment I am developing a Google Chrome Extension in which I have
I am currently developing a Chrome extension in which I have to get the
we are in process of developing google chrome extension, in which we need to
I'm developing an extension for Google Chrome that generates an mp3 file and saves
I am developing a Chrome extension that makes XMLHttpRequest's on various sites but I
I'm developing a Chrome plugin where external scripts are loaded from several domains. I've
I have been developing a chrome extension locally. I just finished it and wanted
I am developing a chrome extension. I found the fact that we have to

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.