By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,635 Members | 2,085 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,635 IT Pros & Developers. It's quick & easy.

help in document.open

parshupooja
100+
P: 159
Hey All,

I am working in asp.net c# and Javascript. I building javascript dynamically.
Actually When user click on button I want new window to open with Yahoo map. If I want map with in a page it works fine. In order to display map in new html page I am using document.open and It seems i have someerror.
Could anyone helpin fixing a bug

here is my code

Expand|Select|Wrap|Line Numbers
  1. StringBuilder str = new StringBuilder();
  2.                             str.Append("<script type=text/javascript>");
  3.                             str.Append("function replace(){");
  4.                             str.Append("window.alert('HH');");
  5.                             str.Append("var oNewDoc = document.open('text/html', 'replace');");
  6.                             str.Append(" var sMarkup='");
  7.                             str.Append("<html>");
  8.                             str.Append("<head>");
  9.                             str.Append("<script language=javascript src=http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=Demo>");
  10.                             str.Append("</script>");
  11.                             str.Append("</head>");
  12.                             str.Append("<body>");
  13.                             str.Append("<div id='mapContainer'></div>");
  14.                             str.Append("<script type=text/javascript>");
  15.                             str.Append("ymap.addPanControl();");
  16.                             str.Append("ymap.addZoomLong();");
  17.                             str.Append("ymap.addTypeControl();");
  18.                             str.Append("ymap.drawZoomAndCenter(60601, 6);");
  19.                             str.Append("function createYahooMarker(customer, address, num) {");
  20.                             str.Append("  var myImage = new YImage();");
  21.                             str.Append("  myImage.src = 'http://us.i1.yimg.com/us.yimg.com/i/us/map/gr/mt_ic_c.gif';");
  22.                             str.Append("  myImage.size = new YSize(20,20);");
  23.  
  24.                             str.Append("  myImage.offsetSmartWindow = new YCoordPoint(0,0);");
  25.  
  26.                             str.Append("  var marker = new YMarker("+address+", myImage);");
  27.  
  28.                              str.Append("var swtext = "+customer + "<br>" + address+";");
  29.                              str.Append("var label = num;");
  30.                              str.Append("marker.addLabel(label);");
  31.                              str.Append("YEvent.Capture(marker, EventsList.MouseClick, function() { marker.openSmartWindow(html) });");
  32.  
  33.                             str.Append("return marker;");
  34.                             str.Append("}");
  35.                             str.Append("var Marker" + i + " = createYahooMarker("+customer+"," + address + ","+order+");");
  36.  
  37.  
  38.  
  39.                             str.Append("ymap.addOverlay(Marker" + i + ");");
  40.  
  41.                             i = i + 1;
  42.                             str.Append("</script>");
  43.                             str.Append("</body>");
  44.                             str.Append("</html>;'");
  45.                             str.Append("oNewDoc.write(sMarkup);");
  46.                             str.Append("oNewDoc.close();");
  47.                             str.Append("}");
  48.                             str.Append("</script>");
please help
Jan 10 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Use window.open() instead.

document.open() opens the current document, not a new one.

As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use the tags in future.

MODERATOR.
Jan 11 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.