2

The problem is that the Visio Web Part opens links in a new window instead of the same window.

The solution could be to configure the web part with JavaScript. I found this code from Jakub Kociubinski, but unfortunately all links still open new windows.

Any ideas about the code? Any other ideas to solve the problem?

<script type="text/javascript"> 
var vwaControl;
var vwaPage;
var vwaPages;
var vwaShapes;
var currentlyAnnotatedShape; 

// Add a handler to the AJAX Sys.Application.load event.
Sys.Application.add_load(onApplicationLoad)

// Capture a reference to the current session of the Visio Web Access Web Part.
function onApplicationLoad() {
    try{
            vwaControl= new Vwa.VwaControl(getVWAWebPartID());
            vwaControl.addHandler("diagramcomplete", onDiagramComplete);
    }
    catch(err){
        alert(err);
    }
}

// Search the SharePoint page to get the WebPartID# for the Visio Web Access Web Part.
function getVWAWebPartID() {

    // Get a NodesList of all the div tags on the page. 
    var divArray = document.getElementsByTagName("div");
    var webPartElementID;

    // Iterate through the NodesList to get the node with the class attribute "VisioWebAccess."
    for (var i = 0; i < divArray.length; i++) {
        var node = divArray[i];

        // Return the first instance of the Visio Web Access Web Part.
        if (node.className == "VisioWebAccess") {
            webPartElementID = node.parentNode.parentNode.id;
            break;
        }
    }
    return webPartElementID;
}

// Capture references to global variables and add handler functions to events.
function onDiagramComplete(){
    try{
        vwaPage = vwaControl.getActivePage();
        vwaShapes = vwaPage.getShapes();
        vwaControl.addHandler("shapeselectionchanged", onShapeSelectionChanged);
    }
    catch(err){
        alert(err);
    }
}

// Open the link in a new window
function onShapeSelectionChanged(source, args){
    try{
        // Ignore the shapeselectionchanged event raised when the selection is cleared.
        if (args != null && args != Sys.EventArgs.Empty){

            var displayMode = vwaControl.getDisplayMode();

            currentlyAnnotatedShape = vwaShapes.getItemById(args);

            var shapeLinks = currentlyAnnotatedShape.getHyperlinks();

            if (shapeLinks.length > 0) {

        link = shapeLinks[0].value;

        // Check if the link is internal
        if(link.indexOf("vdw://") === -1)
        {
            location.href = link;
        }
        else
        {
            var pageLinkName = link.substring(6, link.length -2)

            if(pageLinkName)
            {
                vwaControl.setActivePage(pageLinkName)
            }
        }
            }

        }
    }
    catch(err){
        alert(err);
    }
}
</script>
  • set the option in your browser only to open it in same window? – SharePointMan Jun 11 '15 at 9:39
  • yes, this option is set – 000pd Jun 11 '15 at 13:04
  • I´ve checked shapesheet-settings in Visio as well. The Cell NewWindow is set to FALSE, but still the page opens in a New tab. – 000pd Jun 11 '15 at 15:00
  • I tried to make one hyperlink to another Visio page (in the same Visio file) by selecting sub-address, and this opens in the same window. If I make the hyperlink by paste the url to the SharePoint page in the Address Field, it opens in a New tab. – 000pd Jun 11 '15 at 15:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.