Im trying to load on the click of a div a url but in a new window with certain sizes. For example I would have
<div id="mydiv>
Roy
click on this div
</div>
and
<div id="mydiv>
Alex
click on this div
</div>
Then the idea is a new window will popup ( not a modal ) with say sizes like 300x400px. The username should be passed to this window and I want to be able to do something with it in my web application. Jquery just needs to call something like /chatwindow/?user=rob
What would be a good way to approach this?
Ok, try this
<div id="mydiv-alex" class="mydiv">
Alex click on this div
</div>
<div id="mydiv-jonh" class="mydiv">
Jonh click on this div
</div>
<script>
$('.mydiv').click(function(){
window.open(' /chatwindow/?user='+$(this).attr('id').replace('mydiv-',''), '_blank', 'width=300,height=400');
return false;
});
</script>
try this
<div id="mydiv">
Alex
click on this div
</div>
<script type="text/javascript">
var windowSizeArray = [ "width=200,height=200",
"width=300,height=400,scrollbars=yes" ];
$(document).ready(function(){
$('#mydiv').click(function (event){
var url ="www.yourdomain.com/chatwindow/?user=rob";
var windowName = "popUp";//$(this).attr("name");
var windowSize = windowSizeArray[ $(this).attr("rel") ];
window.open(url, windowName, windowSize);
event.preventDefault();
});
});
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With