---
title: replaceDocument
framework: tvmljs
role: symbol
role_heading: Instance Method
path: tvmljs/navigationdocument/1627430-replacedocument
---

# replaceDocument

Replaces a document on the stack with a new document.

## Declaration

```data
void replaceDocument(
    in Document document, 
    in Document oldDocument
);
```

## Parameters

- `document`: The DOM document that is to be added onto the stack.
- `oldDocument`: The DOM document that is being replaced.

## Discussion

Discussion This function searches the stack for the first instance of the document to be replaced and replaces it with the new document.

## See Also

### Adding Documents to the Stack

- [insertBeforeDocument](tvmljs/navigationdocument/1627340-insertbeforedocument.md)
- [pushDocument](tvmljs/navigationdocument/1627361-pushdocument.md)
