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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:05:31+00:00 2026-05-27T19:05:31+00:00

I have the jQuery function below ( Show_popupWindows ) : $(function () { var

  • 0

I have the jQuery function below (Show_popupWindows) :

    $(function () {
                        var popupWindows_Done = $('input[type="hidden"]#hfpopupWindows_Done').val();
                        if (popupWindows_Done == "false") {
                            Show_popupWindows();
                        }
                        else {
                        }
    });    //End Of $(function ()
    //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
                function Show_popupWindows() {
                    var x = screen.availWidth;
                    //alert(x);
                    $('div#OffDiv').css({ 'width': x });
                    //alert($('div#OffDivAndLoadingContainer').css('width'));
                    var y = screen.availHeight;
                    //alert(y);
                    $('div#OffDiv').css({ 'height': y });
                    //alert($('div#OffDivAndLoadingContainer').css('height'));

                    //alert('On');
                    $('div#OffDiv').css({ 'display': 'block' });
                    $('div#TimerContainer').css({ 'display': 'block' });

                    var w1 = window.open('http://www.blablabla.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);
                    var w2 = window.open('http://www.blablabla.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);
                    window.focus();

                    var sec = $('#TimerContainer span').text()
                    var timer = setInterval(function () {
                        $('#TimerContainer span').text(--sec);
                        if (sec == 0) {
                            clearInterval(timer);
                            $('div#OffDiv').css({ 'display': 'none' });
                            $('div#TimerContainer').css({ 'display': 'none' });
                        }
                    }, 1000);

                    var watchClose = setInterval(function () {
                        try {
                            if (w1.closed || w2.closed) {
                                clearTimeout(watchClose);
                                clearInterval(timer);
                                DoNotClosePoPupWindowDuringTimer();
                            }
                        }
                        catch (e) {
                        }
                    }, 200);
                }
    //>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

how can I put this function into my code behind, so nobody can change this function by editing aspx file.

I tried the method below in code behind :

private static StringBuilder Create_ShowpopupWindows_Function()
{
    StringBuilder sb = new StringBuilder();
    sb.Append("var x = screen.availWidth;");
    sb.Append("//alert(x);");
    sb.Append("$('div#OffDiv').css({ 'width': x });");
    sb.Append("//alert($('div#OffDivAndLoadingContainer').css('width'));");
    sb.Append("var y = screen.availHeight;");
    sb.Append("//alert(y);");
    sb.Append("$('div#OffDiv').css({ 'height': y });");
    sb.Append("//alert($('div#OffDivAndLoadingContainer').css('height'));");

    sb.Append("//alert('On');");
    sb.Append("$('div#OffDiv').css({ 'display': 'block' });");
    sb.Append("$('div#TimerContainer').css({ 'display': 'block' });");

    sb.Append("var w1 = window.open('http://www.almasafzar.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);");
    sb.Append("var w2 = window.open('http://www.soscharge.com', '_blank', 'channelmode=no,directories=yes,location=no,resizable=yes,titlebar=yes,menubar=no,toolbar=no,scrollbars=yes,status=yes', false);");
    sb.Append("window.focus();");

    sb.Append("var sec = $('#TimerContainer span').text()");
    sb.Append("var timer = setInterval(function () {");
    sb.Append("$('#TimerContainer span').text(--sec);");
    sb.Append("if (sec == 0) {");
    sb.Append("clearInterval(timer);");
    sb.Append("$('div#OffDiv').css({ 'display': 'none' });");
    sb.Append("$('div#TimerContainer').css({ 'display': 'none' });");
    sb.Append("}");
    sb.Append("}, 1000);");

    sb.Append("var watchClose = setInterval(function () {");
    sb.Append("try {");
    sb.Append("if (w1.closed || w2.closed) {");
    sb.Append("clearTimeout(watchClose);");
    sb.Append("clearInterval(timer);");
    sb.Append("DoNotClosePoPupWindowDuringTimer();");
    sb.Append("}");
    sb.Append("}");
    sb.Append("catch (e) {");
    sb.Append("}");
    sb.Append("}, 200);");
    return sb;
}

but it does not work when I call it in page_load :

        protected void Page_Load(object sender, EventArgs e)
        {
            StringBuilder sb = Create_ShowpopupWindows_Function();
            ScriptManager.RegisterStartupScript(this, this.GetType(), "Show_popupWindows", sb.ToString(), true);
        }
  • 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-05-27T19:05:31+00:00Added an answer on May 27, 2026 at 7:05 pm

    Instead of creating the script using StringBuilder in code behind to avoid the customer (taking that from your comments on your question) to manipulate the script you can embed the script file in the assembly file.

    1. Right click on the script and selected buid action: Embedded Resource.
    2. Add the script location to the assembly info file:
      [assembly: System.Web.UI.WebResource("SomeFolder.myJavascript.js", "text/js")]
    3. Include the script on the page:

      string scriptLocation =
      Page.ClientScript.GetWebResourceUrl(this.GetType(), "SomeFolder.myJavascript.js");
      Page.ClientScript.RegisterClientScriptInclude("SomeFolder.myJavascript.js", scriptLocation);

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

Sidebar

Related Questions

I have the following jquery function > <script type=text/javascript> > > $(document).ready(function() { >
I have the following jquery code: jQuery(function(){ jQuery(select#rooms).change(function(){ var options = ''; jQuery.getJSON(/admin/selection.php,{id: jQuery(this).val(),
I have the following JQuery code: jQuery(function($) { $j(.follow_btn) .click( function() { var element
I have a jQuery function already to perform the task I need but is
I have a jQuery UI Dialog working great on my ASP.NET page: jQuery(function() {
Here's the story... I have a jQuery function that does something, this function is
I have the following jquery function for filtering the contents of a listbox on
I have a jQuery setInterval function named timerIncrement that times out (stops incrementing the
I have the following jQuery function: $(function(){ if ($(.menu li).hasClass(active)) { $(.active).css(margin-top, 6px); }
I have a jQuery post function that returns a response on success after the

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.