I have a regular page.When i clicked on a button it will be open in that page with some asp controls. what i need is that i want to open that page in a pop up page with close button inside it.I searched but i didn't find a properly cod for this. can any body help me?
thanks
<script type="text/javascript">
function OpenPopup() {
window.open("ProductClass.aspx", "List", "toolbar=no, location=no,status=yes,menubar=no,scrollbars=yes,resizable=no, width=900,height=500,left=430,top=100");
return false;
}
</script>
You can use windows.open in javascript.
<html>
<body>
<script type="text/javascript">
function windowOpen() {
myWindow=window.open('http://myurl.com','_blank','width=200,height=100, scrollbars=no,resizable=no')
myWindow.focus()
}
</script>
<input type="button" value="Open Window" onclick="windowOpen()">
</body>
</html>
Use return before your function
<html>
<body>
<script type="text/javascript">
function windowOpen() {
myWindow=window.open('http://myurl.com','_blank','width=200,height=100, scrollbars=no,resizable=no')
myWindow.focus()
return false;
}
</script>
<asp:button id="btnClick" text="Open Window" onClientClick="return windowOpen()">
</body>
</html>
Use the below code
ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "window.location.href = 'Home.aspx';", true);
hi all Kindly use the below code
function ShowPopup() {
$("#panOne").dialog({
autoOpen: true,
appendTo: "form",
height: 600,
width: 900
});
}
appendTo: "form" is Important as if you are not using it will autopostback all values
Related
I have the following code which seems to be not working.
I want button 2 to enable itself right after the follow click on twitter as well as closing the twitter pop up page.
How can I do it and what's wrong with my current code for enabling button 2?
Thanks ahead,
Appsboss7
Code:
<html>
<head>
<script>
function enableButton2() {
document.getElementById("button2").disabled = false;
}
</script>
</head>
<body>
Follow #BlackShellMedia
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<input type="button" id="button2" value="button 2" disabled />
<script>
$( document ).ready(function() {
$( '#BlackShellMedia' ).click(function() {
enablebutton2();
});
});
</script>
</body>
</html>
I Just can't find the answer to this.
I have a div in my webpage, above on a different layer. I simply want to have a button or tag inside this div which will hide it. I have tried:
<html>
<head>
<script language="javascript">
myFunction()
{
document.getElementById("corporate_background").setAttribute("style", "display:none;");
}
</script>
</head>
<body>
<p>aajhahaksha</p>
<div id="corporate_background">
Close
<P>content...</P>
</div>
</body>
Could someone please show me where I have gone wrong.
Do this:
<html>
<head>
<script language="javascript">
function myFunction()
{
document.getElementById("corporate_background").setAttribute("style", "display:none;");
}
</script>
</head>
<body>
<p>aajhahaksha</p>
<div id="corporate_background">
Close
<P>content...</P>
</div>
</body>
This is just because you didn't define myFunction() as a function .
Next time, open your debugger with F12, and see what it is saying... !
You missed out declaring your function at the beginning
myFunction()
{
document.getElementById("corporate_background").setAttribute("style", "display:none;");
}
You should declare using the keyword function.
function myFunction()
{
document.getElementById("corporate_background").setAttribute("style", "display:none;");
}
You should probably use an event listener on your anchor also instead of using inline javascript. No harm just best practice.
Try this:
<html>
<head>
<script language="javascript">
function myFunction()
{
document.getElementById("corporate_background").style.display='none';
}
</script>
</head>
<body>
<p>aajhahaksha</p>
<div id="corporate_background">
Close
<P>content...</P>
</div>
</body>
</html>
I think what you wanna do is hide the content, so you can hide content like this,
Make the button ;
<button id="btn" name="button">Hide content</button>
By clicking the button it wil hide the div corporate_background
<script>
$(document).ready(function () {
$('#btn').click(function () {
$('#corporate_background').hide();
});
});
</script>
Here is what I have so far:
<html>
<head>
<title>Major League Baseball</title>
</head>
<body>
<script type="text/javascript" language="JavaScript">
document.writeln( "2013 World Series" );
var today= new Date()
$(document).ready(function () {
});
function changeLang(lang) {
document.cookie = 'myCulture=' + lang;
window.location.reload();
return false;
}
link1.onclick = function(e) { return myHandler(e); };
</SCRIPT>
<BODY onload=alert(today)>
<a id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1">Red Sox homepage</a>
<body onload="onload();">
<input type="text" name="enter" class="enter" value="" id="lolz"/>
<input type="button" value="click" onclick="kk();"/>
</body>
</html>
I'm trying to add a javascript function when a link is clicked. I would like the link to open in a new window. Would this be considered a function?
The syntax is like
$('#link1').click(function(){
//any misc code
//window.open('URL','name of url'); <-- to open a new window/tab
});
edit -- missing 's
After reading your comments the following would achieve what you need - I think. (no Jquery, pure javascript)
<script>
function someFunction(){
alert("You called a function on the link click");
}
</script>
<a target="_blank" onclick="someFunction()" id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1">Red Sox homepage</a>
I would change
<a id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1">Red Sox homepage</a>
to
<a id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1" target="_blank">Red Sox homepage</a>
And I would use this to execute a function when this link is clicked.
<script type="text/javascript">
function myHandler(text) {
alert(text);
}
$(document).on('click', 'a#link1', function() {
myHandler($(this).attr('href'));
});
</script>
Edit: Should work when u use this:
<html>
<head>
<title>Major League Baseball</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript">
<script type="text/javascript">
function myHandler(text) {
alert(text);
}
$(document).on('click', 'a#link1', function() {
myHandler($(this).attr('href'));
});
</script>
</head>
<body>
<a id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1">Red Sox homepage</a>
</body>
</html>
All you need to do is change your link to have a target...so just change it to:
<a id="link1" href="http://boston.redsox.mlb.com/index.jsp?c_id=bos&sv=1" target="redsox">
No javascript required.
Sample code:
<html>
<head>
.....
</head>
<body>
<div id="content">
<form>
....
<input type="submit" onclick="loadAnotherPage()"/>
</form>
</div>
</body>
</html>
I want to load another page say edit_profile.php in the content div. How can it be achieved without refreshing the page?
I tried to use jQuery load() method. But looks like I missed something. Any help would be highly appreciated.
When you click submit button it's submit form and page refresh that's why its not working.
Instead of type submit set button and then set function onclick.
function loadAnotherPage(){
$("#content").load('edit_profile.php');
}
$(document).ready(
function() {
$('#load_file').click(
$.post('edit_profile.php',
{},
function(data){
$("#content").html(data);
},''
)
);
}
);
Try this
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<div id="content"></div>
<button id="loadpage">load new page</button>
<script>
$(document).ready(function () {
$("#loadpage").click(function() {
$.get("edit_profile.php", function(response){
$("#content").html(response);
});
})
});
</script>
</body>
</html>
All,
Can u please tell me whats wrong with the following code.I am trying to open a modal window here and the contents of it is a text box.
Also i get the java script error .dialog is not a function.
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("#a").click( function(e) {
e.preventDefault();
var html='<div id="e_ls" style="overflow:auto;text-align:justify"><textarea rows="10" cols="10"></textarea></div>';
$e_ls = jQuery('#e_ls');
$e_ls.html(html);
$("#e_ls").dialog("open");
});
});
</script>
</head>
<a href="" id="a" >a</a>
</html>
Thanks....
Its more than just the Jquery UI File Missing. You are pulling it in incorrectly.
Try:
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#e_ls").dialog({ autoOpen: false });
$("#a").click( function(e) {
e.preventDefault();
$e_ls = jQuery('#e_ls');
$("#e_ls").dialog('open');
});
});
</script>
</head>
<body>
<a href="" id="a" >a</a>
<div id="e_ls" style="overflow:auto;text-align:justify">
<textarea rows="10" cols="10"></textarea>
</div>
</body>
</html>
With the above the e_ls is hidden by default and only called when you ask. Note you do not need the preventDefault() if you put no href in your tag or use a different tag. the preventDefault is only required because you have an active link which also is incorrect...
Ideally you should use a or a if you want to format it like a link you can use CSS <a id="a" style="cursor:pointer; text-decoration: underline; color:00F">a</a>
You need to download and include the jqueryUI code from http://www.jqueryui.com
You need the jQueryui javascript file.