473,406 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

IE7 and window.location not working?

3
Hi,

In a script used by svg, I have a like like the following to go to a new web page:

parent.location.href = newUrl;

This works fine in IE6. However, it has no effect in ie7 (not even a error message, or security message) It just does nothing. (I tried window.location=, window.assign(newUrl), parent.location= .... none of it works, and I don't get an error message)

Where is there information on this? Could anybody advice me anything? Any workaround?

Thanks MR
Apr 18 '07 #1
2 3380
camer
3
I would like to add my code , maybe somebody could be so nice and advice me anything.

I would like to add that the value of 'window.top.location.href is not getting
overwritten with the value newHref.
Does anybody think that I am doing two the same things that are ind the conflict?

Thanks in advance

Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="iso-8859-1"?>
  2. <!-- Following is the DTD emitted by various Adobe products. -->
  3. <!-- !DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN"
  4.    "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/
  5.    svg-20000303-stylable.dtd" -->
  6. <svg id="svg" zoomAndPan="disable" width="700">
  7.  
  8.     <style type="text/css">
  9.         <![CDATA[
  10.             /* In XML you must use a CDATA tag to delimit style content. */
  11.  
  12.             .box {
  13.                 stroke : black;
  14.                 stroke-width : 2;
  15.             }
  16.  
  17.             .border {
  18.                 fill : lightgreen;
  19.                 visibility : hidden;
  20.             }
  21.  
  22.             text {
  23.                 pointer-events : none;
  24.             }
  25.  
  26.             line {
  27.                 stroke : black;
  28.                 stroke-width : 2;
  29.             }
  30.         ]]>
  31.     </style>
  32.  
  33.     <script><![CDATA[
  34.  
  35.                var minX;
  36.                var minY;
  37.                var maxX;
  38.                var maxY;
  39.  
  40.            var RELATED_ENTITY_X       = 380;
  41.            var RELATED_ENTITY_HEIGHT  = 50;
  42.            var RELATED_ENTITY_GAP     = 20;
  43.            var RELATED_ENTITY_WIDTH   = 200;
  44.            var FONT_SIZE              = 15;
  45.            var RELATED_ENTITY_SPACING = RELATED_ENTITY_HEIGHT + RELATED_ENTITY_GAP;
  46.  
  47.            var CIRCLE_RADIUS          = 5;
  48.            var CROWS_FOOT_OFFSET      = 7;
  49.  
  50.            //draw cardinality symbols this proportion from ends of lines
  51.            var OPTIONALITY_POINT      = 0.10;
  52.            var MULTIPLICITY_POINT     = 0.05;
  53.  
  54.            var STROKE_WIDTH_COMPENSATION = 15;
  55.  
  56.            function displayDescription(entityName){
  57.             var loc = decodeURI(location + "");
  58.             if (loc.substr(0, 8) == "file:///") {                
  59.                 loc = loc.substr(8);
  60.                 loc = loc.substr(0, loc.lastIndexOf("/")+1);
  61.                 loc = top.GetAbsolutePathName(loc + "EntityDescription.html");
  62.                 if (!top.FileExists(loc)) alert("returning");    // rather than risk IE crashing in XP SP2
  63.                 }
  64.             alert("loc::"+loc + "?" + entityName);
  65.             //alert("DDParent::" + "file:///" +loc + "?" + entityName);
  66.             //parent.chgUrl(loc + "?" + entityName);
  67.             //window.location.href = loc + "?" + entityName;
  68.             var newHref = "file:///" + loc; 
  69.             alert("newHref::"+newHref);
  70.             // + "?" + entityName;
  71.             alert("location.href::"+location.href);
  72.             alert("parent.location.href::"+parent.location.href);
  73.             alert("parent.parent.location.href::"+parent.parent.location.href);
  74.             alert("There are " + parent.frames.length + "frames");
  75.             alert("Setting href(" + parent.location.href+") to "+newHref);
  76.  
  77.               //href = loc;
  78.               //parent.location.replace(loc);
  79.               //alert("Parent href is now "+parent.location.href);
  80.               //window.location.href = loc + "?" + entityName;
  81.               //parent.parent.location.href = loc + "?" + entityName;
  82.               alert("newHref with entityName::"+newHref+ "?" + entityName);
  83.               //parent.parent.location.assign(newHref+ "?" + entityName);
  84.               //location.href = newHref+ "?" + entityName;
  85.               window.top.location.href = newHref+ "?" + entityName;
  86.               alert("Before return::"+window.top.location.href);
  87.               return newHref+ "?" + entityName;
  88.  
  89.            }
  90.  
  91.            function displayRelationships(entityName){
  92.             var loc = decodeURI(location + "");
  93.             if (loc.substr(0, 8) == "file:///") {
  94.                 loc = loc.substr(8);
  95.                 loc = loc.substr(0, loc.lastIndexOf("/")+1);
  96.                 loc = top.GetAbsolutePathName(loc + "EntityRelationships.html");
  97.                 if (!top.FileExists(loc)) return;    // rather than risk IE crashing in XP SP2
  98.                 }
  99.             alert("DRParent::"+loc + "?" + entityName);
  100.             //window.location.href = loc + "?" + entityName;
  101.               //parent.parent.location.href = loc + "?" + entityName;
  102.            }
  103.  
  104.            function createRelationships()
  105.            {
  106.  
  107.                 if (!checkViewerVersion(true)) {
  108.                     return;
  109.                 }
  110.  
  111.                if (entity == null) {
  112.                    return;
  113.                }
  114.  
  115.             var numRelationships = relationships.length;
  116.  
  117.             var mainEntityText = svgDocument.getElementById("maintext");
  118.             var mainEntityBox = svgDocument.getElementById("mainbox");
  119.  
  120.             var entityName = entity.getAttribute("name");
  121.  
  122.             mainEntityBox.setAttribute("fill",entity.getAttribute("color"));
  123.  
  124.             //position the main box so that its center is level with the middle of the related entities
  125.             //- don't forget to ignore the gap after the last related entity!
  126.  
  127.             var mainEntityHeight  = Number(mainEntityBox.getAttribute("height"));
  128.  
  129.             var mainEntityTop = ((RELATED_ENTITY_SPACING * numRelationships) - RELATED_ENTITY_GAP - mainEntityHeight) / 2;
  130.             mainEntityBox.setAttribute("y", mainEntityTop);
  131.             mainEntityBox.setAttribute("onclick", "displayDescription('" + entityName + "');");
  132.  
  133.  
  134.             mainEntityText.firstChild.nodeValue = entityName;
  135.             mainEntityText.setAttribute("y",mainEntityTop + (mainEntityHeight + FONT_SIZE) / 2 );
  136.             mainEntityText.setAttribute("font-size", FONT_SIZE);
  137.  
  138.  
  139.  
  140.             var mainEntityCenterX = Number(mainEntityBox.getAttribute("x")) + (Number(mainEntityBox.getAttribute("width"))/2);
  141.             var mainEntityCenterY = Number(mainEntityBox.getAttribute("y")) + (Number(mainEntityHeight)/2);
  142.  
  143.             var mainEntityRightEdge = Number(mainEntityBox.getAttribute("x")) + Number(mainEntityBox.getAttribute("width"));
  144.  
  145.  
  146.             var contents = svgDocument.getElementById("contents");
  147.  
  148.             maxX = mainEntityRightEdge;
  149.             maxY = Number(mainEntityBox.getAttribute("y")) + Number(mainEntityBox.getAttribute("height"));
  150.  
  151.             var minLineTouchY = mainEntityTop;
  152.             var maxLineTouchY = mainEntityTop + mainEntityHeight;
  153.  
  154.             var i;
  155.             for(i = 0; i < numRelationships; i++){
  156.                 var relationship = relationships[i];
  157.  
  158.                 var g=svgDocument.createElement("g");
  159.                 contents.appendChild(g);
  160.  
  161.                 var x = RELATED_ENTITY_X;
  162.                 var y = RELATED_ENTITY_SPACING * i;
  163.  
  164.                 //create the line
  165.  
  166.                 var line=svgDocument.createElement("line");
  167.                 g.appendChild(line);
  168.  
  169.                 //we draw the line towards the center of the main entity
  170.  
  171.                 //identify the point where this line crosses the main entity's right edge
  172.  
  173.                 var lineRelatedEntityY = y + RELATED_ENTITY_HEIGHT / 2;
  174.                 var lineMainEntityY = mainEntityCenterY + (lineRelatedEntityY - mainEntityCenterY) * (mainEntityRightEdge - mainEntityCenterX) / (x - mainEntityCenterX);
  175.  
  176.                 if (lineMainEntityY < minLineTouchY) {minLineTouchY = lineMainEntityY;}
  177.                 if (lineMainEntityY > maxLineTouchY) {maxLineTouchY = lineMainEntityY;}
  178.  
  179.                 line.setAttribute("x1",x);
  180.                 line.setAttribute("y1",lineRelatedEntityY); 
  181.  
  182.                 line.setAttribute("x2",mainEntityRightEdge);
  183.                 line.setAttribute("y2",lineMainEntityY); 
  184.  
  185.                 //draw cardinalities at the main entity end                
  186.                 drawCardinalities (g, x, lineRelatedEntityY, mainEntityRightEdge, lineMainEntityY, relationship.getAttribute("this.cardinality"));
  187.  
  188.                 //draw cardinalities at the related entity end                
  189.                 drawCardinalities (g, mainEntityRightEdge, lineMainEntityY, x, lineRelatedEntityY, relationship.getAttribute("related.cardinality"));
  190.  
  191.                 var relatedEntityName = relationship.getAttribute("related.name");
  192.  
  193.  
  194.                 //create a hyperlink (don't specify the target; just used to cause the mouse pointer to change)
  195.                 var a=svgDocument.createElement("a");
  196.  
  197.                 g.appendChild(a);
  198.  
  199.                 var rect=svgDocument.createElement("rect");
  200.                 a.appendChild(rect);
  201.  
  202.                 rect.setAttribute("x",x);
  203.                 rect.setAttribute("y",y); 
  204.                 rect.setAttribute("height",RELATED_ENTITY_HEIGHT);
  205.                 rect.setAttribute("width",RELATED_ENTITY_WIDTH );
  206.                 rect.setAttribute("class","box");
  207.  
  208.                 rect.setAttribute("fill",relationship.getAttribute("related.color"));
  209.  
  210.                 rect.setAttribute("onclick","displayRelationships('" + relatedEntityName + "')");
  211.  
  212.                 var rectMaxX = Number(rect.getAttribute("x")) + Number(rect.getAttribute("width"));
  213.                 var rectMaxY = Number(rect.getAttribute("y")) + Number(rect.getAttribute("height"));
  214.  
  215.                 if (rectMaxX > maxX) {maxX = rectMaxX;}
  216.                 if (rectMaxY > maxY) {maxY = rectMaxY;}
  217.  
  218.                 var text=svgDocument.createElement("text");
  219.                 a.appendChild(text);
  220.  
  221.                 text.setAttribute("x",x + RELATED_ENTITY_WIDTH / 2);
  222.  
  223.                 text.setAttribute("y",y + (RELATED_ENTITY_HEIGHT + FONT_SIZE) /2); 
  224.                 text.setAttribute("text-anchor","middle");
  225.                 text.setAttribute("font-size", FONT_SIZE);
  226.  
  227.                 var textValue = svgDocument.createTextNode(relatedEntityName);
  228.                 text.appendChild(textValue);
  229.  
  230.  
  231.             }
  232.  
  233.             //size the main entity to ensure that all lines touch
  234.             mainEntityBox.setAttribute("y", minLineTouchY);
  235.             mainEntityBox.setAttribute("height", maxLineTouchY - minLineTouchY);
  236.  
  237.             minY = 0;
  238.             if (numRelationships == 0) {minY = minLineTouchY;}
  239.             if (maxLineTouchY > maxY)  {maxY = maxLineTouchY;}
  240.  
  241.             //finally set the initial zoom so that the whole document is displayed
  242.  
  243.             var svg = svgDocument.getElementById("svg");
  244.             svg.setAttribute("viewBox", 
  245.                 (0 - STROKE_WIDTH_COMPENSATION) + " " + 
  246.                 (minY - STROKE_WIDTH_COMPENSATION) + " " +
  247.                 (maxX + 2 * STROKE_WIDTH_COMPENSATION) + " " + 
  248.                 (maxY - minY + 2 * STROKE_WIDTH_COMPENSATION)
  249.             );
  250.  
  251.            }
  252.  
  253.  
Apr 18 '07 #2
camer
3
The st does not allow for submitting long messages so I needed to split the code into parts. There is a next one.

Expand|Select|Wrap|Line Numbers
  1.  
  2.            function drawCardinalities(g, x1, y1, x2, y2, cardinalityDesc) {
  3.  
  4.  
  5.             var optional;
  6.             var many;
  7.  
  8.             if (cardinalityDesc == "0..1") {
  9.                 optional = true;
  10.                 many = false;
  11.             } else if (cardinalityDesc == "1..1") {
  12.                 optional = false;
  13.                 many = false;
  14.             } else if (cardinalityDesc == "0..*") {
  15.                 optional = true;
  16.                 many = true;
  17.             } else if (cardinalityDesc == "1..*") {
  18.                 optional = false;
  19.                 many = true;
  20.             } else {
  21.               //not recognized
  22.               return;
  23.             }
  24.  
  25.  
  26.             //work out the point to draw lines near the entity
  27.             var optx = (OPTIONALITY_POINT * x1) + ((1 - OPTIONALITY_POINT) * x2 );
  28.             var opty = (OPTIONALITY_POINT * y1) + ((1 - OPTIONALITY_POINT) * y2 );
  29.  
  30.  
  31.  
  32.                if (optional) {
  33.                    //draw a circle
  34.  
  35.                 var circle=svgDocument.createElement("circle");
  36.                 g.appendChild(circle);
  37.  
  38.                 circle.setAttribute("cx",optx);
  39.                 circle.setAttribute("cy",opty); 
  40.                 circle.setAttribute("r",CIRCLE_RADIUS); 
  41.  
  42.                 circle.setAttribute("fill","white");
  43.                 circle.setAttribute("stroke","black");
  44.                 circle.setAttribute("stroke-width",3);
  45.             } else {
  46.  
  47.                 //work out length of the main line using Pythagorus
  48.  
  49.                 var mainline_length = Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
  50.  
  51.                 //draw a bar perpendicular to the line
  52.  
  53.                 var BAR_LENGTH = 5;
  54.                 var barx1 = optx + BAR_LENGTH * (y2 - y1) / mainline_length;
  55.                 var barx2 = optx - BAR_LENGTH * (y2 - y1) / mainline_length;
  56.                 var bary1 = opty - BAR_LENGTH * (x2 - x1) / mainline_length;
  57.                 var bary2 = opty + BAR_LENGTH * (x2 - x1) / mainline_length;
  58.  
  59.  
  60.                 var line=svgDocument.createElement("line");
  61.                 g.appendChild(line);
  62.  
  63.  
  64.                 line.setAttribute("x1",barx1);
  65.                 line.setAttribute("x2",barx2);
  66.                 line.setAttribute("y1",bary1);
  67.                 line.setAttribute("y2",bary2);
  68.             }
  69.  
  70.             if (many) {
  71.                 //draw a crow's foot
  72.  
  73.                 //work out the point to draw lines near the entity
  74.                 var multix = (MULTIPLICITY_POINT * x1) + ((1 - MULTIPLICITY_POINT) * x2 );
  75.                 var multiy = (MULTIPLICITY_POINT * y1) + ((1 - MULTIPLICITY_POINT) * y2 );
  76.  
  77.                 var polyline=svgDocument.createElement("polyline");
  78.                 g.appendChild(polyline);
  79.  
  80.                 var points = "";
  81.                 points += String(x2) + ", " + String(y2 + CROWS_FOOT_OFFSET) + " ";
  82.                 points += String(multix) + ", " + String(multiy)  + " ";
  83.                 points += String(x2) + ", " + String(y2 - CROWS_FOOT_OFFSET) + " ";
  84.  
  85.                 polyline.setAttribute("points",points);
  86.                 polyline.setAttribute("stroke","black");
  87.                 polyline.setAttribute("stroke-width",2);
  88.                 polyline.setAttribute("fill","none");
  89.  
  90.             }
  91.  
  92.            }
  93.            ]]>
  94.  
  95.             function checkViewerVersion(displayMessage) {
  96.  
  97.                var WRONG_ASV_VERSION = 'Please ensure you are using version 3.0 of the Adobe'
  98.                    + ' SVG viewer. This viewer is available for download'
  99.                    + ' from http://www.adobe.com/svg.';
  100.  
  101.                if (!window || !window.navigator || !window.navigator.appVersion
  102.                    || window.navigator.appVersion.indexOf("3.0") == -1) {
  103.                  if (displayMessage) {
  104.                    alert(WRONG_ASV_VERSION);
  105.                  }
  106.                  return false;
  107.                } else {
  108.                  return true;
  109.                }
  110.             }           
  111.     </script>
  112.  
  113.     <g id ="all">
  114.         <!-- backdrop so events are picked up at every pixel -->
  115.         <rect id = "backdrop" fill="white" width="700"/>
  116.         <g id="contents" onload="createRelationships()">
  117.             <a>
  118.                 <rect id="mainbox" x="0" y="100" height="300" width="200" class="box"/>
  119.                 <text id="maintext" x="100" y="100" text-anchor="middle"> </text>
  120.             </a>
  121.         </g>
  122.     </g>
  123. </svg>
  124.  
Apr 18 '07 #3

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

Similar topics

10
by: Scott | last post by:
I'm new to ASP, but I've been programming in VB for several years, and I'm having a few issues with this ASP enhancement I'm working on. I've found ASP to be a lot different than what I'm use to...
2
by: venkatesh | last post by:
Hi Members, I have used the below mentioned code to open a html page in a new browser. The window size is 200 x 300. In that browser, I've given code to open another browser of the same size....
1
by: Tersia Ehlert | last post by:
Hi I have an .NET web application where I redirect a page on submit to a blank page where the code below runs client side. I want to, with this code, refresh two frames - the one my page was...
5
by: spam_me_ not | last post by:
I already understand that one cannot disable a browser's forward and back functions. This is a situation where I have code working in Mozilla V1.6 and would like something similar for Opera and...
2
by: voodoolv | last post by:
So.. I have a javascript that makes a popup with a javscript function in it. The function in the popup after 5 seconds tries to change the "price" field value in the opener window: sourze=...
2
by: Dennis Ålund | last post by:
Is it possible to notice a change of window.location.hash without polling? I'm working on a Ajax-platform (yes, inventing the wheel again) and have finished almost everything except the support...
8
by: johnsonholding | last post by:
Here is the code for a pop-up window that works in Firefox and not in IE - I get a java error or something, Here is the code : </script> <SCRIPT language="JavaScript"...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
6
mikewagan
by: mikewagan | last post by:
hello guys, Javascript's been bugging on IE, and i'm trying to search for a solution for this answer but no luck. I have a select box as a navigation element. If a user clicks on an option, it...
1
by: vinpkl | last post by:
hi all i have two dynamic drop downs of dealer id and category id which work properly with window.location var dealerid; function getList(xyz) {...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.