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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:37:39+00:00 2026-05-16T23:37:39+00:00

I am facing problem while resizing an image in the Popup brwoser window. Image

  • 0

I am facing problem while resizing an image in the Popup brwoser window.

Image present in popup gets resized when the user resizes the browser window for the first time only, afterwards when the window resizes (dblclicking the titlebar, or using the resize handles) the image dimension remains equal to the last resized dimension.

My code is shown below:

<html>
<head>
    <title>Enlarged Image</title>
    <script language="javascript" type="text/javascript">
       var arrTemp=self.location.href.split("?");
       var picUrl = (arrTemp.length>0)?arrTemp[1]:"";
       var NS = (navigator.appName == "Netscape") ? true : false;

       function GetWidth() {
           var x = 0;
           if (self.innerHeight) {
               x = self.innerWidth;
           }
           else if (document.documentElement && document.documentElement.clientHeight) {
               x = document.documentElement.clientWidth;
           }
           else if (document.body) {
               x = document.body.clientWidth;
           }
           return x;
       }

       function GetHeight() {
           var y = 0;
           if (self.innerHeight) {
               y = self.innerHeight;
           }
           else if (document.documentElement && document.documentElement.clientHeight) {
               y = document.documentElement.clientHeight;
           }
           else if (document.body) {
               y = document.body.clientHeight;
           }
           return y;
       }

       window.onresize = function() { document.write("<img src='" + picUrl + "' border=0 Name=image Width=" + GetWidth() + " Height=" + (GetWidth() * 3) / 4 + "/>") }           

    </script>
</head>
<body style='margin: 0px; text-align:center;'>
    <script language="javascript" type="text/javascript">
        document.write("<img src='" + picUrl + "' border=0 Name=image Width=800 Height=600 />");            
    </script>
</body>

I am passing imgpath to this html file from my aspx file as shjown below:

this.aspHyperlink.NavigateUrl = "javascript:PopupPic('." + this.aspImgCtrl.ImageUrl.Replace('~', '.') + "')";

The javascript PopupPic function is shown below:

function PopupPic(sPicURL) {
    window.open("PopupEventImage.htm?" + sPicURL, "", "resizable=1,HEIGHT=600,WIDTH=800");
}

Any ideas for resizing the image every time the user resizes the popup window?

  • 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-16T23:37:40+00:00Added an answer on May 16, 2026 at 11:37 pm

    From what I can see, every time you resize the window, you are rewriting the img tag. What you should be doing is changing the width and height attributes of the tag.

    Also, it looks like your code is ripe for cross-site scripting attacks.

    An example of code that would work but keep the cross-site scripting problem:

    <html>
    <head>
        <title>Enlarged Image</title>
        <script language="javascript" type="text/javascript">
           var picUrl = "http://www.google.com/images/logos/ps_logo2.png&quot;;
           function GetWidth() {
               var x = 0;
               if (self.innerHeight) {
                   x = self.innerWidth;
               }
               else if (document.documentElement && document.documentElement.clientHeight) {
                   x = document.documentElement.clientWidth;
               }
               else if (document.body) {
                   x = document.body.clientWidth;
               }
               return x;
           }
           function GetHeight() {
               var y = 0;
               if (self.innerHeight) {
                   y = self.innerHeight;
               }
               else if (document.documentElement && document.documentElement.clientHeight) {
                   y = document.documentElement.clientHeight;
               }
               else if (document.body) {
                   y = document.body.clientHeight;
               }
               return y;
           }
           function Resize() {
               var img = document.getElementById("mainImage"); 
               img.src = picUrl; 
               img.width = GetWidth();
               img.height = (GetWidth() * 3) / 4;
           }
           window.onresize = Resize;
           // Call Resize onload to get the initial sizing correct
           window.onload = Resize;
           </script>
    </head>
    <body style='margin: 0px; text-align:center;'>
        <img border=0 id=mainImage Width=800 Height=600 />
    </body>
    

    I would suggest an alternate approach in general. Don’t have a PopupEventImage.htm file. Instead, make that an ASP.NET file that takes a value from something the user cannot edit. Session state for example. That way, malicious users cannot inject scripting attacks into your page. I can provide an example of this if you’d like.

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

Sidebar

Related Questions

i am using mvc 3 code first. facing problem while passing data form SecurityAttribute
I am facing a problem while saving a .csv file from browser. I made
I am facing problem while setting the backGround Image of LinearLayout from asset folder.
I am facing problem while setting focus in EdiText. Below is my EditText property.
I am facing problem while generating CAB file. I want to customize the INF
I am facing a problem while creating a static cursor in DB2. This is
I'm facing a problem while deleting a record that is referenced by another table.
I am facing a problem while disabling the command button after one click. I
I am facing the problem while inserting data this way. How to insert data
I am new to Android development and facing a problem while using AndEngine. I

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.