Modal dialog options - javascript

I am opening a window as a modal.
window.showModalDialog("http://www.google.com","","dialogWidth:500px;dialogHeight:500px")
as I set height, what are other options available?
Like option buttons, menus etc. where I can find tutorials?
EDIT
It works in Mozilla firefox, but people are saying it doesn't!
My code is
Please somebody Edit my sample code for display purpose
<html>
<head>
<script>
function abc() {
window.showModalDialog("3.htm", "", "dialogWidth:500px;dialogHeight:500px");
}
</script>
</head>
<body>
<input type="button" id="check" name="check" onclick="abc()" value="open"/>
</body>
</html>
Second EDIT
code for page 3.htm
<html>
<head>
<script>
function abc(){
close()
}
</script>
</head>
<body>
<input type="button" id="check" name="check" onclick="abc()" value="close"/>
</body>
</html>
Check out both code on fire fox! and tell me.
Third EDIT
Ok It's not working in corme and opera

Be aware that showModalDialog is IE specific and won't necessarily work with other browsers. If you want cross browser modal dialogs you need to use a div to hide the rest of the page and overlay your dialog on top. It is easier to use an existing javascript library that already takes care of this.

I suggest not to use popups in web apps. Use floating divs instead which looks like a modal dialog but are better than the popups.

JQuery UI has a decent popup/modal dialog API and I've worked with the Boxy plugin which is very easy to implement.
They're cross browser and simple to use.

To load a page using boxy use:
var boxyPopup;
Boxy.load("aPage.html",
{title: "Title",
modal: true,
fixed: false,
afterShow: function(){
boxyPopup = this;}});
I'm not sure what you mean by it not opening a new page on same boxy window but using the above you have the boxyPopup var as a reference to the open boxy object and can access/change contents using that.

Related

How to open popups automatically after certain time (without blocking)

I am making a web page, in which I have to open a popup window from an buton after 8 seconds(8000 ms).
I want to put some delay(8 seconds) before a popup open automatically.
my problem is that mozilla firefox block my popup
Here is my code:
<html>
<head>
<script>
function call()
{
popup = window.open('http://www.google.co.in');
}
function caller()
{
setInterval(call, 8000);
}
</script>
</head>
<body>
<input type="button" onclick="caller();">
</body>
</html>
There is no way around a browser's popup blocking/displaying architecture. All you can do is call the JS method. What happens then is outside the HTML/JS purview.
Javascript popups are really kind of out of fashion on the web, because of the blockers. They're annoying, their behavior depending on device is unpredictable, and generally, users hate them. Consider another approach.
You should use the function setTimeout(functionName , delay) instead of setInterval. setInterval will popup a new window every 8 seconds while setTimeout will only do it once.
<html>
<head>
<script>
function call()
{
popup = window.open('http://www.google.co.in');
}
setTimeout(call, 8000);
</script>
</head>
<body>
<input type="button" onclick="caller();">
</body>
</html>
And I'm agree, look for an another way to do what you want. Popups are often a inconvenience for users, especially for partially-sighted person.
By default many web browser block automatic popup. They only alow popup for direct action like in an onClick envent.

How to Open a Hyperlink (2) in the same window which was opened with a click to Hyperlink1

I am working on a requirement with a (Parent) web page having some links suppose Link1,Link2 and Link3.when i click Link1 which will be opened in a new window which is active window1 (child) and when i click Link2/Link3 the page should open in the same window (window1) .
Question:
Is there a way in Javascript/Jquery/Ajax to implement this functionality.Please do share your valuable thoughts on this.
Note:
If none of the links are opened then a new window should pop up. I know that we have Option target="_blank/_self/_top" etc in HTML.
You want to create your own named window.
Just add target="SomeName" to all of the links, and they will reuse the named window if it still exists.
Since you have asked the JS/ jQuery way,
JavaScript way is,
window.open('http://www.example.org','window1');
<html>
<head>
<script>
function open_win(url)
{
window.open(url,"hello","",true);
}
</script>
</head>
<body>
Google <br>
Yahoo <br>
Gmail
</body>
</html>
Issue is resolved thanks,i Thought too much / some thing else which lead this misconception. Thanks

Is it possible to disassemble html?

For testing purpose I create simple html with one button. When you click on button it show you alert. I try to to change button text value with olly, ida, and cheatengine to some other value but it doesn't work. Why?
Is it possible to change value of variable of html, is it possible to disassemble program like iexplorer?
Simple html on what i worked look like this:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function myFunction()
{
alert("I am an alert box!");
}
</script>
</head>
<body>
<input type="button" onclick="myFunction()" value="Show alert box" />
</body>
</html>
If you're using Internet Explorer 9, hit F12 to enable the developer tools. This will show you the structure of your HTML, which you can then change. These will also allow you (via the Script tab) to set breakpoints and debug your JavaScript. From here you can change variable values.
For older versions of IE, similar functionality (though not including JavaScript debugging) is available in the Developer Toolbar.
If you're using FireFox, try FireBug.
If you're using Google Chrome, hit F12 to display the developer tools.
Your terminology isn't correct by the way: HTML does not get compiled (or assembled), so the idea of disassembling it isn't valid. The word you're probably looking for is debug.
If you're using Internet Explorer, don't hit F12 to enable the developer tools. This will only show you the structure of your HTML badly, which you can then change with difficulty.
Instead, make sure you're using FireFox, and then install the extension FireBug which will enable you to view and edit HTML/CSS and Javascript live in the browser (and much more).
Is this what you mean you want?
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function olly()
{
alert("Olly");
}
function cheatengine()
{
alert("cheatengine");
}
</script>
</head>
<body>
<input type="button" onclick="olly()" value="olly" />
<input type="button" onclick="cheatengine()" value="cheatengine" />
</body>
</html>

JavaScript Code to make external site pop-up

i need a javascript code that would enable me, on a certain button click to let a panel open which contains another page not under my domain for example, www.google.com!
Press Here and upon pressing it, a popup will appear or a panel will become visible that contains Google.com in it!
thanks!
In a function that you bind to the click event for the element you want to click on: Create an iframe and set its src, then append it to an element already in the document.
I'd look into using jquery http://docs.jquery.com/How_jQuery_Works
It's hosted on a CDN so it's easy to include in a document and many browsers will already have it cached decreasing the pages load time.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
jquery is a lightweight javascript library that makes selecting and manipulating page elements REALLY easy.
$("#button").click(function () {
$("#hiddenDiv").slideDown();
});
The hidden div should contain an iframe to display the off-domain page.
http://www.w3schools.com/html/html_iframe.asp
Oh and if you need to dynamically assign the iframe then look into the jquery append function http://api.jquery.com/append/
$('#hiddenDiv').append('<iframe src="http://www.google.co.uk"></iframe>');
This should put you on the right tracks.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#show_frameDiv').click(function(){
$('#frameDiv').show();
});
});
</script>
<style>
#frameDiv { display: none; }
#frameDiv iframe { width: 100%; height: 600px; }
</style>
</head>
<body>
Show external site
<div id="frameDiv">
<iframe src="http://www.bbc.co.uk">
<p>Your browser does not support iframes.</p>
</iframe>
</div>
</body>
This will work only if the site you are trying to display allows frames. Otherwise you may need to open the site in a separate browser window.
use window.Open method like this:
window.open ("www.google.com","mywindow");
see
http://www.javascript-coder.com/window-popup/javascript-window-open.phtml
for more details.

Javascript cross window interaction

I have this very simple Javascript to write on a text area when the link is clicked:
<head>
<script language="javascript" type="text/javascript">
function addtext(text) {document.form.textarea.value = document.form.textarea.value+= text;}
</script>
</head>
<body>
<form action="" method="" name="form">
<textarea name="textarea" rows="" cols="" wrap="wrap"></textarea>
</form>
q
</body>
Now I want to up the ante.
What I want to do is have the form in another another window, and that when I click the link, I writes to a textarea in another window.
I'm not necessarily asking for the code because I realize this might be quite complicated.
The question would be where to start, because I havenĀ“t got a clue!!
(when I Google cross window or cross domain interaction with Javascript I don't really get anything useful).
So any help I can get, libraries, plugins or whatever might guide me in the right direction is more than appreciated.
Ok, I wrote you a sample you can check at http://jsfiddle.net/zzdAL/
$(document).ready(function()
{
popup = window.open("http://fiddle.jshell.net");
$("#input1").click(function() {
try {
popup.document.window.alert(1);
}
catch (e) { alert(e.message); }
});
}
);
It only runs an alert on the popup, but you can do whatever you want with the popup, assuming you have the necessary rights (needs to be the same domain I believe).
The most simple is to write a function in your popup and call it from the opener.
Probably it's too late, but here is an example of interaction: window interaction
Take a look to greasemonkey, it's an addon for your browser.
You can choose on which page(s) the script will works.
http://wiki.greasespot.net/Main_Page

Categories

Resources