I have one file have name: 1.html writed code:
<HEAD>
<TITLE>WINDOWS</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function openWindow(url,name) {
popupWin = window.open(url, name, "scrollbars=yes,width=800, heigth=200 ");
}
function m(a) {
popupWin = alert('Click ok');
}
</SCRIPT>
</HEAD>
<BODY>
<a name="123" href="javascript:m(this.a)">oPen</a>,<br>
<input type="button" value="-link-" onclick="m(this.a)">
</BODY>
</HTML>
-------------------
i want to write one file with name 2.html
can control fuction m(a) of file 1.html
when open 2.html will run m(a) and show "click ok"
Help me! Thanks everyone
I can use to investigate the function from the file. html not. because if it is. js, you can use the src = “http://example/file.js.” but if a file is “. html” from a different page, you can call it?
As I understand it you want a button on 1.html to fire an alert on 2.html. The following script does that, but you need to move the new window away from the main window so that the alert doesn’t hide behind the window holding 1.html.
The function with the alert is part of the the new page 2.html.
// ===== 1.html ================
<html>
<head>
<title>This is 1.html</title>
<script type=“text/JavaScript”>
<!–
// global ref used to communicate with new window
var popupWin=null;
//
// open new window
function openWindow(urlA,nameA)
{ // check to see if popupWin already exists
if(!popupWin || popupWin.closed)
{ popupWin=window.open(urlA, nameA, “scrollbars=yes,width=200,height=200”);
}
else
{ popupWin.focus();
}
}
// ======== end open window =========
//–>
</script>
<style type=“text/css”>
<!– #main { position:absolute; top:100px; left:100px; width:100px; height:100px; text-align:left; } #main p { margin-top:0px; margin-bottom:10px; }
–>
</style>
</head>
<body>
<div id=“main”>
<p class=“zz”><a name=“123” href=“javascript: openWindow(‘2.html’,‘winA’)”>Open</a></p>
<p><input type=“button” value=“-link-” onclick=“window.popupWin.m()”>
</div>
<!-- end main –>
</body>
</html>
// ======= this is 2.html ================
<html>
<head>
<title>This is 2.html</title>
<script type=“text/javascript”>
<!–
function m()
{ alert(‘Click ok’);
}
//–>
</script>
</head>
<body>
<p>This is your new window. Click the link in the first window to fire the alert
in this window</p>
------>
ok!Thanks very much u! u undestanded think of me! But i want call a function from web another.So i can’t call
Example: function showAlert() input at http://example.com/file_1.html
And i can’t change this.
Can u help me call function showAlert from another website? Thanks!