Holland
Holland

Reputation: 422

Javascript resizing of Firefox pop-up window?

I'm just learning Javascript and jQuery, but I'm an HTML'r trying to take the next step..

I'm attempting to drop content into a table, which can be any size at all (It's for a news site). I check for size and then resize the popup accordingly; while the window isn't exactly right it works, but in Firefox it's not even resizing.

Using a generic link to pop-open a basic window:

<a onclick="window.open('http://site.local/popup/','popup','width=1,height=1')">popup</a> 

I'm pointing it to a default page where the cms is placing all content into a table (id="top"). It has a default width="1" to force a constraint, and then letting the content expand the table to set the real size. I then check the table size to see and resize the window on document.ready():

<script type="text/javascript">
 <!--
 $(document).ready(function() {
  var divh = document.getElementById('top').offsetHeight;
  var divw = document.getElementById('top').offsetWidth;

  //Test size
  //alert("Table: width= " + divw + "px / height= " + divh +"px");

  //Resize
  window.resizeTo(divw,divh);
  }    
 -->
</script>

I need to be able to resize a window already opened in Firefox.

All the window sizes (except Firefox) are off but I can pad them - a little larger is better than cut-off. Firefox, unfortunately, generates a tiny 180w x 249h window and never resizes.

I've searched here unsuccessfully - most suggest editing a setting in firefox, which I clearly can't expect users to do.

Any ideas?

Upvotes: 8

Views: 5933

Answers (4)

Tyler Schroeder
Tyler Schroeder

Reputation: 730

I would highly recommend replacing your popup with a div popup. You're going to run into issues like you have with Firefox, and browsers blocking it altogether. Assuming you have jqueryui included and you're loading this content from the same domain:

$('#container').load('/popup',function() {
     var table = $('#container #top');
    $('#container').dialog({height:table.height(), width: table.width()});
});

Upvotes: 1

Zefiryn
Zefiryn

Reputation: 2265

Why not getting the content with ajax request and display it in a div above the current content?

Upvotes: 0

timdream
timdream

Reputation: 5922

Firefox comes with a preference for user to allow/disallow resizing of window using Javascript. It's in Tools - Options - Content - Enable Javascript -> [Advanced].

I am not sure if resizing is disabled by default, but you might want to check your own Firefox installation first.

If it's disabled by default, then unfortunately there is nothing you could do to resize the window after it has been opened. An ugly workaround would be to open itself once again using window.open() with the preferred size though.

Upvotes: 0

BusterLuke
BusterLuke

Reputation: 298

Try something like this;

<a class='poptrigger'>pop</a>

$(function(){
 var w = $("#top").outerWidth();
 var h = $("#top").outerHeight();
 $('.poptrigger').click(function{
  window.open('http://site.local/popup/','popup','width='+w+',height='+h)
 })
});

That way you shouldn't need to resize the window, but just set the size initially.

Upvotes: 0

Related Questions